Algorithm Search⌘K

Proofs: PageRank

These are the human proofs of PageRank, at full length.

Power iteration converges to the unique PageRank vector full

This proof shows: correctness, termination.

We use the notation of the page. Vectors are row vectors, ∥z∥1=∑v∣zv∣\|z\|_1 = \sum_v |z_v|, and Δ={x∈Rn:x≥0,∑vxv=1}\Delta = \{x \in \mathbb{R}^n : x \ge 0, \sum_v x_v = 1\} is the set of probability vectors. Let 0≤α<10 \le \alpha < 1.

The matrices. Let SS be the n×nn \times n matrix with Suv=cuv/d+(u)S_{uv} = c_{uv}/d^+(u) when d+(u)>0d^+(u) > 0, and Suv=1/nS_{uv} = 1/n when uu is dangling. Each row of SS is non-negative and sums to 1, so SS is stochastic. Let J=1n11TJ = \tfrac{1}{n}\mathbf{1}\mathbf{1}^T. The Google matrix is P=αS+(1−α)JP = \alpha S + (1 - \alpha) J, which is the matrix of the page: for a dangling uu, α/n+(1−α)/n=1/n\alpha/n + (1 - \alpha)/n = 1/n.

Lemma 1 (one round computes xPxP). If x∈Δx \in \Delta at the start of a round, then at the end of line L6, y=xPy = xP, and y∈Δy \in \Delta.

Proof. After line L5, yv=∑(u,v)∈Exu/d+(u)=∑u:d+(u)>0xuSuvy_v = \sum_{(u, v) \in E} x_u / d^+(u) = \sum_{u : d^+(u) > 0} x_u S_{uv}, because the cuvc_{uv} copies of an arc from uu to vv each add xu/d+(u)x_u/d^+(u). Line L4 sets d=∑u danglingxud = \sum_{u \text{ dangling}} x_u, and ∑u danglingxuSuv=d/n\sum_{u \text{ dangling}} x_u S_{uv} = d/n. So after line L6,

yv=α∑uxuSuv+1−αn=α(xS)v+(1−α)(xJ)v=(xP)v,y_v = \alpha \sum_u x_u S_{uv} + \frac{1 - \alpha}{n} = \alpha (xS)_v + (1 - \alpha)(xJ)_v = (xP)_v,

where (xJ)v=1n∑uxu=1n(xJ)_v = \tfrac1n \sum_u x_u = \tfrac1n because x∈Δx \in \Delta. Every entry of PP is non-negative and each row sums to 1, so xP≥0xP \ge 0 and ∑v(xP)v=∑uxu=1\sum_v (xP)_v = \sum_u x_u = 1. □\square

Lemma 2 (SS does not expand the L1L_1 norm). For every z∈Rnz \in \mathbb{R}^n, ∥zS∥1≤∥z∥1\|zS\|_1 \le \|z\|_1.

Proof. ∥zS∥1=∑v∣∑uzuSuv∣≤∑v∑u∣zu∣Suv=∑u∣zu∣∑vSuv=∥z∥1\|zS\|_1 = \sum_v |\sum_u z_u S_{uv}| \le \sum_v \sum_u |z_u| S_{uv} = \sum_u |z_u| \sum_v S_{uv} = \|z\|_1. □\square

Lemma 3 (contraction). For x,x′∈Δx, x' \in \Delta, ∥xP−x′P∥1≤α∥x−x′∥1\|xP - x'P\|_1 \le \alpha \|x - x'\|_1.

Proof. Let z=x−x′z = x - x'. Then ∑uzu=0\sum_u z_u = 0, so zJ=0zJ = 0, and zP=αzSzP = \alpha zS. By Lemma 2, ∥zP∥1≤α∥z∥1\|zP\|_1 \le \alpha \|z\|_1. □\square

Theorem. (a) There is exactly one π∈Δ\pi \in \Delta with π=πP\pi = \pi P. (b) Let x(0)x^{(0)} be the uniform vector of line L1 and x(k)x^{(k)} the vector after kk rounds. Then ∥x(k)−π∥1≤2αk\|x^{(k)} - \pi\|_1 \le 2\alpha^k. (c) The loop stops after a finite number of rounds, and the returned vector xx satisfies ∥x−π∥1≤αε/(1−α)\|x - \pi\|_1 \le \alpha\varepsilon/(1 - \alpha).

Proof. By Lemma 1 and induction on kk, every x(k)x^{(k)} lies in Δ\Delta and x(k+1)=x(k)Px^{(k+1)} = x^{(k)}P.

(a) The set Δ\Delta is a closed subset of Rn\mathbb{R}^n, so it is complete under ∥⋅∥1\|\cdot\|_1. By Lemma 1 the map f(x)=xPf(x) = xP sends Δ\Delta into Δ\Delta, and by Lemma 3 it is a contraction with factor α<1\alpha < 1. The Banach fixed-point theorem gives exactly one fixed point π∈Δ\pi \in \Delta. For a direct proof of uniqueness: if π\pi and π′\pi' are both fixed, then ∥π−π′∥1=∥πP−π′P∥1≤α∥π−π′∥1\|\pi - \pi'\|_1 = \|\pi P - \pi' P\|_1 \le \alpha \|\pi - \pi'\|_1, so ∥π−π′∥1=0\|\pi - \pi'\|_1 = 0.

(b) Since π=πP\pi = \pi P, Lemma 3 gives ∥x(k+1)−π∥1=∥x(k)P−πP∥1≤α∥x(k)−π∥1\|x^{(k+1)} - \pi\|_1 = \|x^{(k)}P - \pi P\|_1 \le \alpha \|x^{(k)} - \pi\|_1. By induction, ∥x(k)−π∥1≤αk∥x(0)−π∥1\|x^{(k)} - \pi\|_1 \le \alpha^k \|x^{(0)} - \pi\|_1. Two probability vectors are at L1L_1 distance at most ∥x(0)∥1+∥π∥1=2\|x^{(0)}\|_1 + \|\pi\|_1 = 2.

(c) Termination. The value of δ\delta computed in round k≥1k \ge 1 is δ(k)=∥x(k)−x(k−1)∥1\delta^{(k)} = \|x^{(k)} - x^{(k-1)}\|_1. By Lemma 3 applied k−1k - 1 times, δ(k)≤αk−1δ(1)≤2αk−1\delta^{(k)} \le \alpha^{k-1} \delta^{(1)} \le 2\alpha^{k-1}. If α=0\alpha = 0, then $x^{(1)} = x^{(0)}P = $ the uniform vector, so δ(1)=0<ε\delta^{(1)} = 0 < \varepsilon and the loop stops after one round. If 0<α<10 < \alpha < 1, then 2αk−1<ε2\alpha^{k-1} < \varepsilon as soon as k−1>log⁡(ε/2)/log⁡αk - 1 > \log(\varepsilon/2)/\log\alpha, so the loop stops after at most ⌈log⁡(ε/2)/log⁡α⌉+1\lceil \log(\varepsilon/2)/\log \alpha \rceil + 1 rounds.

Error at the stop. Let the loop stop after round kk, so δ(k)<ε\delta^{(k)} < \varepsilon and the result is x=x(k)x = x^{(k)}. By the triangle inequality and (b),

∥x(k−1)−π∥1≤∥x(k−1)−x(k)∥1+∥x(k)−π∥1≤δ(k)+α∥x(k−1)−π∥1,\|x^{(k-1)} - \pi\|_1 \le \|x^{(k-1)} - x^{(k)}\|_1 + \|x^{(k)} - \pi\|_1 \le \delta^{(k)} + \alpha \|x^{(k-1)} - \pi\|_1,

so ∥x(k−1)−π∥1≤δ(k)/(1−α)\|x^{(k-1)} - \pi\|_1 \le \delta^{(k)}/(1 - \alpha). Then ∥x(k)−π∥1≤α∥x(k−1)−π∥1≤αδ(k)/(1−α)<αε/(1−α)\|x^{(k)} - \pi\|_1 \le \alpha \|x^{(k-1)} - \pi\|_1 \le \alpha \delta^{(k)}/(1 - \alpha) < \alpha \varepsilon/(1 - \alpha). ■\blacksquare

The fixed point is the PageRank vector. The equation π=πP\pi = \pi P, read entry by entry with ∑uπu=1\sum_u \pi_u = 1, is the formula of the page: πv=α∑(u,v)∈Eπu/d+(u)+αn∑u danglingπu+1−αn\pi_v = \alpha \sum_{(u,v) \in E} \pi_u/d^+(u) + \tfrac{\alpha}{n}\sum_{u \text{ dangling}} \pi_u + \tfrac{1 - \alpha}{n}. Since every entry of PP is at least (1−α)/n(1 - \alpha)/n, the chain is irreducible and aperiodic for α<1\alpha < 1, and π\pi is its stationary distribution.

Back to PageRank