2013-03-04 31 views
0

我试图计算具有多个边的图的点击次数我已经写在networkx小代码如下:命中计算在图形networkx

import networkx as nx 
import matplotlib.pylab as plot 
g=nx.read_pajek("D:\Slash.net") 
h,a=nx.hits(g) 

但是,当我试着执行我的代码以下错误:

Traceback (most recent call last): 
File "<stdin>", line 1, in <module> 
File "C:\Python27\lib\site-packages\networkx-1.7-py2.7.egg\networkx 
\link_analysis\hits_alg.py", line 74, in hits 
raise Exception("hits() not defined for graphs with multiedges.") 
Exception: hits() not defined for graphs with multiedges. 

对它请看看 感谢和问候!

+2

也许你的图有多个。 – 2013-03-04 15:03:02

回答

1

read_pajek函数返回g作为MultiGraph或MultiDiGraph。用nx.Graph(g)将它转换成简单的图形。