Reputation: 434
I have a directed multi graph. With networkx 2.0 I found that the edges are returned as tuple made of (start_node, end_node, integer), where the integer is generated to distinguish multiple edges between same nodes.
With networks 1.x I could get an edge using:
edge = G.edge[start_node][end_node]
With v2.0 this doesn't work anymore, because "edges" isn't a nested dict anymore. A change to:
edge = G.edges(start_node, end_node)
doesn't work "{ValueError}too many values to unpack (expected 3)", because it misses the integer to identify the single edge within the multi edge. Whether or not multiple edges exist between nodes isn't fixed, same for the number of multi edges.
Does that mean I always have to iterate over edges?
Upvotes: 0
Views: 763
Reputation: 23897
According to the networkx 1.x -> 2.0 migration guide:
Replace any use of
G.edge
withG.adj
. The Graph attributeedge
has been removed. The attributeG.adj
isG.edge
in v1 and will work with both versions.
This migration guide is a fairly quick read, and to my experience is a pretty comprehensive guide to all the things that break going from 1.x to 2.0.
Upvotes: 2