def pagerank_limit_push ( s , r , w_i , a_i , push_node , rho ) : # Calculate the A and B quantities to infinity A_inf = rho * r [ push_node ] B_inf = ( 1 - rho ) * r [ push_node ] # Update approximate Pagerank and residual vectors s [ push_node ] += A_inf r [ push_node ] = 0.0 # Update residual vector at push node's adjacent nodes r [ a_i ] += B_inf * w_i
python initialize pagerank vector
Performs a random step without a self - loop .
def pagerank_limit_push(s, r, w_i, a_i, push_node, rho):
    """
    Performs a random step without a self-loop.
    """
    # Calculate the A and B quantities to infinity
    A_inf = rho*r[push_node]
    B_inf = (1-rho)*r[push_node]

    # Update approximate Pagerank and residual vectors
    s[push_node] += A_inf
    r[push_node] = 0.0

    # Update residual vector at push node's adjacent nodes
    r[a_i] += B_inf * w_i