Reputation: 2160
MyNetwork is an instance of networkx.MultiDiGraph. I'm wondering if multiple runs of the following code is guaranteed to result exactly the same list containing all edges (along with edge attributes) in MyNetwork:
AllEdges = [(from_node,to_node,edge_key,edge_attributes) for (from_node,to_node,edge_key,edge_attributes) in MyNetwork.edges(keys=True,data=True)]
Thank you for your kind answer.
Upvotes: 4
Views: 619
Reputation: 25289
The list of edges returned from the MultiDiGraph.edges() method is not guaranteed to be in any order or the same when called repeatedly. You'll have to do more processing (e.g. a sort) or maintain a separate list or symbol table of edges if you need a particular ordering.
Upvotes: 4