Search code examples
pythonigraphpagerank

Does igraph (python) implementation of PageRank include self-loops?


I work on igraph on python with a weighted directed network with several self-loops. I have computed the pagerank of the nodes with igraph considering their respective weights and directed = True. In the literature I found the computation of PageRank takes into account the outdegree of nodes for its "random walk" (http://www.math.ryerson.ca/~abonato/webgraph.html), however it does not explicitly say what is done with self-loops.

Am I right in assuming igraph considers self-loops in the computation of PageRank?


Solution

  • Testing this:

    edges1 = [(0,1),(1,2),(2,3),(1,1)]
    edges2 = [(0,1),(1,2),(2,3)]
    
    test1 = Graph(directed = True)
    test2 = Graph(directed = True)
    for i in xrange(4):
        test1.add_vertex(i)
        test2.add_vertex(i)
    
    test1.add_edges(edges1)
    test2.add_edges(edges2)    
    
    print(test1.pagerank())
    #[0.10419852083404119, 0.33524741485734993, 0.24667867214841493, 0.3138753921601939]
    print(test2.pagerank())
    #[0.11615582303660361, 0.2148882726177167, 0.29881085476166275, 0.37014504958401695]
    

    Yes.

    editted for code brevity.