On Thu, Nov 26, 2009 at 1:22 AM, Sudarshan Iyengar
<
sudars...@gmail.com> wrote:
> considering a path of length 10
>>>>G=nx.path_graph(10)
>
> pagerank_numpy gives:
>
> [0.064384752387429953,
..
>
> But the largest eigen vector is
> [0.12013116478919983,
..
>
> The values are very different... Pagerank essentially computes the
> largest eigenvector right? Is there anything wrong with the
> pagerank_numpy function or is something wrong in my understanding of
> pagerank?
It depends on what you mean by "largest eigenvector". Pagerank
computes the eigenvector for the largest eigenvalue of the "Google
Matrix" which is related to the adjacency matrix.
http://en.wikipedia.org/wiki/Google_matrix
import networkx as nx
import numpy
edges=[(1,2),(1,3),\
(3,1),(3,2),(3,5),\
(4,5),(4,6),\
(5,4),(5,6),\
(6,4)]
G=nx.DiGraph(edges)
# find largest eigenval/eigenvec pair using linpack
M=nx.google_matrix(G,alpha=0.9)
e,ev=numpy.linalg.eig(M.T)
p=numpy.array(ev[:,0]/ev[:,0].sum())[:,0] # normalize
# 0.03721197 0.05395735 0.04150565 0.37508082 0.20599833 0.28624589]
print p
# numpy iterative version
print nx.pagerank_numpy(G,alpha=0.9)
# Python version
print nx.pagerank(G,alpha=0.9).values()
Aric