2013-03-04 32 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)將它轉換成簡單的圖形。