Gary Shea
unread,Nov 8, 2010, 10:55:51 AM11/8/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to networkx-discuss
Hello,
I am fairly new to networkx, so this may be very simple. If anyone can
tell me why this example works for Graphs, DiGraphs and MultiGraphs,
but does not work for MultiDiGraphs, I would appreciate it.
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G.add_edge('a','b',weight=2)
>>> G.add_edge('b','c',weight=4)
>>> G.size()
2
>>> G.size(weighted=True)
6.0
Many thanks to anyone who enlightens me. Here is what I get when I try
to re-create the example:
>>> G=nx.MultiDiGraph()
>>> G.add_edge('a','b',weight=2)
>>> G.add_edge('b','c',weight=4)
>>> G.size()
2
>>> G.size(weighted=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python31\lib\site-packages\networkx-1.3-py3.1.egg\networkx
\classes\gr
aph.py", line 1614, in size
s=sum(self.degree(weighted=weighted).values())/2
File "C:\Python31\lib\site-packages\networkx-1.3-py3.1.egg\networkx
\classes\gr
aph.py", line 1241, in degree
return dict(self.degree_iter(nbunch,weighted=weighted))
File "C:\Python31\lib\site-packages\networkx-1.3-py3.1.egg\networkx
\classes\mu
ltidigraph.py", line 490, in degree_iter
for (n,succ,pred) in nodes_nbrs:
ValueError: need more than 2 values to unpack
>>>