Link Graph Encyclopedia

PageRank in depth

Power iteration

Start from any distribution and apply one random-surfer step to all nodes at once, over and over. The error shrinks by a factor of about α per pass, and each pass reads every link exactly once.

Power iteration is the simplest way to compute PageRank and most other spectral rankings. Start with a guess, typically the uniform distribution. Apply the PageRank equation’s right-hand side to get a new vector. Repeat until the vector stops changing. Each pass costs one scan over all arcs. The method is old, it is slow compared with more sophisticated solvers, and it has computed more rankings than any other algorithm because it is easy to implement, parallelise and reason about.

The algorithm

p = [1/n] * n
repeat:
    D = sum of p[u] over dangling nodes u
    q = [(1 - α + α·D) / n] * n            # teleport and dangling mass
    for each arc u → v:
        q[v] += α · p[u] / outdeg[u]
    change = sum |q - p|
    p = q
until change < ε

The loop over arcs is the whole cost. On a graph with mm arcs and nn nodes, one pass is O(n+m)O(n + m) time with two vectors of nn entries in memory. The order in which arcs are visited does not change the result, which makes the pass easy to split across threads or machines.

Why it converges

One pass computes pk+1=pkGp_{k+1} = p_k G, where GG is the PageRank matrix: the row-stochastic matrix combining links, dangling jumps and teleportation. GG has largest eigenvalue 1 with the PageRank vector as its eigenvector (see Perron–Frobenius). Writing the error in terms of GG’s other eigenvectors, each pass multiplies the component along eigenvector ii by λi\lambda_i, so the error decays like ∣λ2∣k|\lambda_2|^k, where λ2\lambda_2 is the second-largest eigenvalue in modulus. Haveliwala and Kamvar showed that ∣λ2∣≤α|\lambda_2| \le \alpha for the PageRank matrix. A direct argument bounds every pass, not only the long run: the error sums to zero, so the teleport term cancels and one pass shrinks the error’s L1 norm by at least a factor α\alpha. The starting error is at most 2, so

∥pk−p∥1≤2αk.\| p_k - p \|_1 \le 2\alpha^k .

With α=0.85\alpha = 0.85, every 14 passes gain about one decimal digit. The bound does not depend on nn: a graph with 7 nodes and a graph with 120 million nodes need about the same number of passes for the same precision.

Worked example

On the running example, starting from the uniform vector 1/71/7:

Pass C A G B D, F E Change
1 0.339 0.178 0.117 0.117 0.097 0.056 4.6×10−14.6 \times 10^{-1}
2 0.279 0.233 0.192 0.123 0.063 0.047 2.7×10−12.7 \times 10^{-1}
5 0.293 0.208 0.181 0.137 0.065 0.051 2.5×10−22.5 \times 10^{-2}
10 0.298 0.205 0.178 0.138 0.065 0.051 1.4×10−31.4 \times 10^{-3}
20 0.298 0.205 0.177 0.138 0.065 0.051 2.4×10−62.4 \times 10^{-6}
43 0.298 0.205 0.177 0.138 0.065 0.051 6.5×10−136.5 \times 10^{-13}

Between passes 20 and 30 the change falls by a factor of 750, about 0.52 per pass, faster than the bound of 0.85, because the two dangling nodes send every visitor back to a random node. The ranking settles long before the values do: from pass 2 on, the order C, A, G, B, D = F, E never changes.

When to stop

The change between passes is easy to measure, but it is not the error. For PageRank the two are related by

∥pk−p∥1≤α1−α ∥pk−pk−1∥1,\| p_k - p \|_1 \le \frac{\alpha}{1 - \alpha}\, \| p_k - p_{k-1} \|_1 ,

so with α=0.85\alpha = 0.85 the true error can be 5.7 times the observed change. Common choices:

Speeding it up

Pull or push

The loop above pushes: it reads each node’s out-links and adds to its targets. The pull form reads each node’s in-links from the transposed graph and sums contributions into one entry at a time. Pull needs the transpose but writes each entry once, so parallel threads never conflict; push needs only the forward graph but parallel writes to the same target must be synchronised. Large-scale implementations, including LAW’s, use the transposed graph and pull. PageRank at scale covers the memory and bandwidth arithmetic.

Beyond PageRank

The same loop computes eigenvector centrality (without teleport, normalising each pass), Katz centrality and HITS (alternating two products). None of them enjoys PageRank’s guarantee: their convergence rate depends on the graph’s own eigenvalue gap, which can be tiny, and periodic graphs can make the iterates oscillate forever. The teleport term is what makes PageRank’s power iteration reliably fast.

References

Edit this entry on GitHub