New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export graph to file #18828
Comments
Commit: |
Branch: u/ncohen/18828 |
New commits:
|
comment:3
Hello, The patchbot reports compilation errors associated with ticket #18746. I don't know why... Concerning this ticket. Don't feel guilty to steal networkx. It is very useful and we will certainly also have to do the same for reading graphs from file. I suggest to change the way you guess the file format with something like:
With networkx it is possible to give extension like David. |
comment:4
Hellooooo! I have a little trouble understanding the goal of this ticket: would you like to have only one standard function to save graphs, instead of calling different NetworkX functions, right? Because, for instance, if I want to save a file in adjlist format I can simply type:
instead of using this new function. In any case, I have tried to compile this code, both with
|
comment:5
Hello,
I had the same problem. Can be solved by removing all the cython cached files that you can find:
And then it works. That's trouble for the patchbots, though.
Yep.
Why? It is longer, and does the same. None of the extensions contains a point.
So you want to add all combinations of Nathann |
comment:6
Hello,
Yes
That's what the branch does, too. Only you may not know that those functions can be found in networkx.
I added one check, but it is unpleasant in many ways. First, the (integer) vertices become strings, and then each edge gets a label encoding a weight. Well, that's networkx...
How is that not a guess? Anyway, udpated.
Done. Nathann |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:9
This method is clearly useful. It is too boring to import networkx each time you want to read/write a graph from/to a file.
By default method
instead of
I understand that you prefer short and fast code, but since writing to a file is slow anyway, we could spend some computation time to refine the behavior of the method. David |
comment:10
Would it do the trick for you if we replaced 'networkx.write_edgelist' with 'lambda x:networkx.write_edgelist(x,data=False)'? Nathann |
comment:11
Replying to @nathanncohen:
Nice trick. Furthermore, in case we want to write the labels, we can have another parameter to set data=True. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:13
Some functions have this 'data' flag, others do not. To make everything simpler I updated the code to make it possible to forward any other flag to networkx. This way, we can pick whatever we want. Nathann |
comment:14
I propose to add extend the tests in the following way. Let me know if you agree before I push a commit.
Relying on vertex names is unfortunately not possible yet since the read method turns vertex id like |
comment:15
No problem no problem. Or perhaps we could relabel the graph with the function 'int' ? This should turn the u'13' into a proper 13. Nathann |
Changed branch from u/ncohen/18828 to u/dcoudert/18828 |
comment:17
I have pushed a small edit on the example. Hope it helps. For the unicode problem, I have once used the following trick. Certainly not the best way to do it.
New commits:
|
comment:18
Works for me ! |
comment:19
So then good to go. It would be nice to have a method for importing a graph from file, but I don't know where to put it: as a method of class |
Reviewer: David Coudert |
comment:20
The 'classiest way' would probably be something like Nathann |
comment:21
I understand. Although you did an impressive cleaning, it's still hard. |
Changed branch from u/dcoudert/18828 to |
I feel rather guilty, as all that this branch does is steal networkx functions. With it we can export graphs to several file formats, using the
networkx.write_*
functions.Nathann
CC: @dimpase @dcoudert @sagetrac-borassi
Component: graph theory
Author: Nathann Cohen
Branch/Commit:
254b36c
Reviewer: David Coudert
Issue created by migration from https://trac.sagemath.org/ticket/18828
The text was updated successfully, but these errors were encountered: