Repository navigation
bugfix-for-issue-4353: modify default edge_id format - #4842
Conversation
|
Thanks for the PR! I don't understand the concern about global uniqueness. If the user is able to select the edge attribute used for the edge_id, they can make it unique on whatever scale is needed. If someone prefers to use MG = nx.MultiGraph([(1, 2), (2, 3), (1, 2)])
nx.set_edge_attributes(MG, {e: str(e) for e in MG.edges}, "eid")
nx.write_graphml(MG, path, graphml_edge_id_attribute="eid") |
|
Thanks for the suggestion!! I agree that it will be flexible with the selection of edge_attribute. (e.g. BTW, I have no idea what the cause of build errors in the CI pipeline is. Do I miss something important? |
|
The circleci build error is confusing. It is using an old setup to run, but it looks like your branch has the new stuff. For instance, it is installing dependencies for cartopy. But we don't do that now and you seem to have the new circleci config that doesn't install those dependencies. Circleci is also installing |
|
I think circleci itself recently had a "release" where a bunch of new features were added - it looks like this PR may have just been caught up in some hiccups related to circleCI's changes - I agree that there's no reason why this should've had problems. Hopefully things are settling down a bit now - restarting the workflow seems to have done the trick |
|
Thanks for your support for the circleCI build errors. I remove my previous implementation and add one extra input argument, The usage like below G = nx.MultiDiGraph(((0, 1, 0, {"eid": 1}), (0, 1, 1, {"eid": 2}), (1, 2, 0, {"eid": 3}), (2, 0, 0, {"eid": 4})))
nx.write_graphml(G, path, edge_id_from_attribute="eid")
nx.generate_graphml(G, edge_id_from_attribute="eid") |
|
The new input argument should be made the last argument to avoid messing up the calling order with legacy code. It looks like you only use this functionality for MultiGraph inputs. Can you extend it to work for the other types: Graph, ..., ... What does the |
|
I update the code to move the new input argument to the last and also extend the functionality to non-MultiGraph objects (e.g. Graph, DiGraph). Regarding the testing, I split MultiGraph and simple Graph into two different cases since networkX handles I think |
|
Hi @dschult, is there anyone who could take a look at my fix? Thanks for your time. |
dschult
left a comment
There was a problem hiding this comment.
This looks ready to merge.
Thanks very much!
rossbar
left a comment
There was a problem hiding this comment.
The implementation + tests LGTM. I think the parameter description in the docstring needs to clarified a bit though as I wasn't able to understand what this new parameter does without reading the code itself. See comment for further discussion.
rossbar
left a comment
There was a problem hiding this comment.
Excellent, thanks @berlincho !
Allow selection of an edge attribute to be the edge id when writing GraphML. Adds edge_id_from_attribute kwarg.
Allow selection of an edge attribute to be the edge id when writing GraphML. Adds edge_id_from_attribute kwarg.
The issue is about failing to preserve edge global uniqueness while calling
write_graphml()in MultiGraph format with thekeysfield.My idea is to write the edge_id in
id = (src, dest, key)format, instead ofid = key. While selecting one of the edge attributes to be the edge_id might be viable, it would cause the loss of local uniqueness when reading the graphML.This is the first time that I open a pull request in this project. Happy to discuss the issue with the contributors.