I have found that the order matters, that networkx only looks at links
in one direction:
>>> G = nx.DiGraph()
>>> G.add_edges_from([(0, 1), (1, 2), (2, 0)])
>>> G.edges()
[(0, 1), (1, 2), (2, 0)]
However we only get two edges when converting to undirected using the
shallow copy method:
>>> nx.Graph(G).edges()
[(0, 1), (1, 2)]
The deep copy method is correct:
>>> G.to_undirected().edges()
[(0, 1), (0, 2), (1, 2)]
________
If I reverse the order of the last edge pair, from (2,0) to (0,2) all is well:
>>> G = nx.DiGraph()
>>> G.add_edges_from([(0, 1), (1, 2), (0, 2)])
>>> G.edges()
[(0, 1), (0, 2), (1, 2)]
>>> nx.Graph(G).edges()
[(0, 1), (0, 2), (1, 2)]
>>> G.to_undirected().edges()
[(0, 1), (0, 2), (1, 2)]
________
What is the best practice to handle this, given that the graphs are
coming from an external file so I am unsure which order the edges will
be specified in?
thanks
Simon
It's a bug. I opened a ticket at https://networkx.lanl.gov/trac/ticket/564
There should be a simple fix.
Aric
Cheers
Simon
> --
> You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
> To post to this group, send email to networkx...@googlegroups.com.
> To unsubscribe from this group, send email to networkx-discu...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/networkx-discuss?hl=en.
>
>