-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
len(G.edges) unexpected values #2734
Copy link
Copy link
Closed
Description
I'm not sure if this is a bug or expected behavior but it's at least confusing. This is using 2.0 nx.Graph() - I would provide the data to recreate, but it's private and I'm not sure why this is occurring, which might just be my lack of knowledge
>>> len(G.edges())
300
>>> G.number_of_edges()
312
>>> count = 0
>>> s = set()
>>> for edge in G.edges():
... seen = edge in s or (edge[1], edge[0]) in s
... if not seen:
... count += 1
... s.add(edge)
>>> count
312
What would be likely reasons that len() would give a different answer than number_of_edges()? I thought it was because of reversed edges, but that doesn't seem to be the case either.
Reactions are currently unavailable