0

I'm trying to run NetworkX's pagerank on a really big graph (DiGraph) and I'm always getting this error:

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

I tried removing all nodes with zero degree, but I still get the same error.

Maehler
  • 6,111
  • 1
  • 41
  • 46
Tal Baumel
  • 31
  • 6
  • Looking at the code (stochastic_graph() in stochastic.py) I don't see how a divide by zero should ever happen. Can you reproduce it in a simple case? – Aric Mar 29 '13 at 22:20

1 Answers1

0

It would be good to see more of your code. As it is one can speculate on possible causes:

  • Page rank works on undirected graphs (see the docs and this previous question. Could the error be caused by pagerank trying to convert edges to two undirected edges?

  • Also, does this make a difference?

    rank = nx.pagerank(self.G.to_undirected(), 0.9, vector)

Community
  • 1
  • 1
daedalus
  • 10,873
  • 5
  • 50
  • 71