igraph / python-igraph

Python interface for igraph
GNU General Public License v2.0
1.28k stars 247 forks source link

Power iteration method ignores reset_vertices in personalized pagerank #101

Closed alessioguerrieri closed 7 years ago

alessioguerrieri commented 7 years ago

Hi, I'm running personalized pagerank on a large graphs (~600000 nodes) and since I do not care too much about the precision, I wanted to try the power iteration method instead of the default prpack. Sadly, it seems that the reset_vertices parameter is not used. I've created a small example:

import igraph
g= igraph.Graph()
g.add_vertices(3)
g.add_edges([(0, 1), (1, 2), (1, 0), (2, 1)])
print(g.pagerank(implementation="power"))
print(g.personalized_pagerank(reset_vertices=[0], implementation="power"))
print(g.personalized_pagerank(reset_vertices=[1], implementation="power"))
print(g.personalized_pagerank(reset_vertices=[2], implementation="power"))

All calls return the same results, just as if the personalized pagerank was called with the uniform distribution.

ntamas commented 7 years ago

Do not use the power method. It is a naive implementation, it was used back in the early days of igraph as the only algorithm, but PRPACK is superior in every sense - and it is likely to be faster as well. The old power method is kept around for compatibility reasons only, and it will probably be removed soon. Also, as far as I know, the old naive implementation is prone to stopping too early before convergence is reached.