我正在尝试在一个非常大的图表(DiGraph)上运行NetworkX的pagerank并且我总是收到此错误:
Traceback (most recent call last):
File "summarize.py", line 120, in <module>
s = summerizer().summ(q)
File "summarize.py", line 108, in summ
rank = nx.pagerank(self.G, 0.9, vector)
File "/usr/local/lib/python2.7/dist-packages/networkx/algorithms/link_analysis/pagerank_alg.py", line 93, in pagerank
W=nx.stochastic_graph(D, weight=weight)
File "/usr/local/lib/python2.7/dist-packages/networkx/generators/stochastic.py", line 42, in stochastic_graph
d[weight]=d.get(weight,1.0)/degree[u]
ZeroDivisionError: integer division or modulo by zero
我尝试删除零度的所有节点,但我仍然得到相同的错误。
答案 0 :(得分:0)
看到更多代码会很高兴。因为人们可以推测可能的原因:
网页排名适用于无向图(请参阅docs和此previous question。错误可能是由于尝试将边缘转换为两个无向边的页面错误造成的吗?
此外,这会有所作为吗?
rank = nx.pagerank(self.G.to_undirected(),0.9,vector)