Closed 6bdad4c1-1e26-4f2f-a442-a01a2292c181 closed 14 years ago
Apparently now, networkx has moved to having a dictionary of edge attributes, rather than a specific "label". See http://networkx.lanl.gov/reference/api_1.0.html#edge-attributes
I'm not saying we should follow the convention, but it does seem to make sense. Instead of just storing a single value, store a dict of attributes.
Why is it important that dictionaries are not hashable?
Because I sometimes stored them as keys of dictionaries. It means I will need to forget to store the label, and just the endpoints. The other detail is that in many algorithms, the labels are used as a weight, and I you will see very often in Sage's code : weight = lambda label : 1 if label is None else label
So all these occurrences need to be replaces to label == {} in this case... Does that mean we should assume labels are ALWAYS dictionaries ? This would mean trouble... Where would we store numerical values for edges then.. a default field ?
Nathann
A little farther down the networkx page listed, we find http://networkx.lanl.gov/reference/api_1.0.html#converting-your-existing-code-to-networkx-1-0, which says that now all algorithms (in Networkx) look for the "weight" edge attribute.
Sounds like that would be a huge change for Sage code, though...
Hi Nathann,
Thanks for uncovering this one. Not sure right now I have a good idea about what should be done.
However, is there a patch to go on this? I'm not seeing one.
Rob
Not yet. For the moment, my patch is a nasty one : replaces tests "is None" by "is None or == {}". I thought it may be better to settle on what we want to do with these labels, but I can upload it otherwise (somewhere on another computer at the moment) :-)
Nathann
Here is a patch that does not make any choice. I replaced the "is None" by "in RR" :-)
The failing docstrings come from GraphViz ( at least on my computer ) !
Nathann
Now also fixes the edge_coloring function from the graph_coloring module, as reported by Minh in #8781
Sorry for that !
Nathann
Attachment: trac_8892.patch.gz
Attachment: trac_8892-reviewer.patch.gz
I'm mostly happy with trac_8892.patch. I have attached a reviewer patch that deals with the part I'm not happy with, i.e. fix some typos introduced by the first patch. Apart from myself, anyone is welcome to give a final sign off on this ticket.
Author: Nathann Cohen
Reviewer: Minh Van Nguyen
I sign off on your changes. Are you asking someone else to also sign off on the original patch?
(I didn't apply your changes, but it is clear that they are cosmetic things.)
Replying to @jasongrout:
Are you asking someone else to also sign off on the original patch?
Not really. I'm OK with ncohen's patch.
Changed reviewer from Minh Van Nguyen to Minh Van Nguyen, Jason Grout
Merged: sage-4.4.2.rc0
Hello everybody !!!
I noticed working on something quite different that many doctests were failing in Sage's graph library because of the recent update of NetworkX... The reason is easy : the default edge label is not "None" anymore but {}. Besides, dictionary are not hashable !!!
This patch fixes it !
Nathann
Component: graph theory
Author: Nathann Cohen
Reviewer: Minh Van Nguyen, Jason Grout
Merged: sage-4.4.2.rc0
Issue created by migration from https://trac.sagemath.org/ticket/8892