PageRank (Brin and Page, 1998) scores a page by the long-run fraction of time a random surfer spends there: $PR(p) = (1-d)/N + d\sum_{q \to p} PR(q)/L(q)$, with the rank of pages without out-links spread over all pages. This article proves that with uniform teleportation and a damping factor $d < 1$, the Google matrix $G$ has exactly one stationary vector, positive and summing to 1. Every other eigenvalue of $G$ is $d$ times one of the stochastic link matrix $S$, so $\lvert \lambda_2 \rvert \le d$, with equality on webs with two or more closed traps, as the real web has. Power iteration's error shrinks at least by the factor $d$ each step. On the five-page web with $d = 0.85$, $A$ ($0.3171$) edges out $C$ ($0.3113$), and the iteration takes 40 steps where the bound allows 142.
A crawl leaves behind more than pages: its connectivity server knows which pages link to which. The text-matching methods of the earlier topics, from TF-IDF to BM25, ignore the links and score a page by its content. On the web, content is easy to manipulate and quality varies enormously. Early web search engines therefore returned many pages that matched a query's words and were useless. Can the links alone say which pages matter most? They can say which pages are linked to by pages that are themselves well linked, and that turns out to be a useful measure of importance, with limits set out at the end.
The links offer another kind of evidence. A link from one page to another is a small judgment by its author that the target is worth visiting. The method called PageRank (Brin and Page, 1998; Page, Brin, Motwani, and Winograd, 1999) turns the whole web's links into a score of importance for each page. It is computed once from the link graph a crawler collects, and used as one signal in ranking. This article is also the course's full treatment of Markov chains, stationary distributions and power iteration, so later articles can link here rather than repeat them.
The article builds PageRank the way a course in applied linear algebra does. First a thought experiment, the random surfer, becomes a formula that we solve by hand. Then the formula becomes a matrix in three stages: the raw link matrix $H$, the stochastic matrix $S$ that repairs pages without links, and the Google matrix $G$ that adds random jumps. PageRank is the dominant eigenvector of $G$, and the eigenvalues explain why it exists, why it is unique, and how fast power iteration finds it. Then we read it as a Markov chain and as a linear system, and turn to personalized PageRank, a summary of HITS (which has its own article), and the limits of link analysis. Worked problems from the course text close the article. A five-page web is carried through every step, with every matrix entry and intermediate value shown.
The random surfer
PageRank is defined by a thought experiment. A surfer starts on a random page and clicks links forever. At each step, from the current page, the surfer picks one of its out-links at random and follows it. Over a long time, the surfer visits some pages much more often than others: pages with many in-links, and especially pages with in-links from pages that are themselves often visited. A page's PageRank is the long-run fraction of time the surfer spends there.
Following links alone does not quite work. A page with no out-links, called a dangling page, traps the surfer. A group of pages linking only to each other would capture the surfer forever, and pages that link into the group receive nothing back. The fix is teleportation: at each step, with probability $1 - d$, the surfer ignores the links and jumps to a page chosen uniformly at random from all $N$ pages. With probability $d$, called the damping factor, it follows a link as before. From a dangling page, it always teleports. Brin and Page used $d = 0.85$. On a web without dangling pages, the number of links followed between two jumps is then geometric: the surfer follows exactly $k$ links and then jumps with probability $(1-d)\,d^k$. Its mean is
$$\sum_{k=0}^{\infty} k\,(1-d)\,d^k = (1-d)\,d \sum_{k=1}^{\infty} k\,d^{k-1} = \frac{(1-d)\,d}{(1-d)^2} = \frac{d}{1-d} \approx 5.67,$$
using $\sum_{k \ge 1} k\,d^{k-1} = 1/(1-d)^2$, the derivative of the geometric series $\sum_{k \ge 0} d^k = 1/(1-d)$. So the surfer follows between five and six links, on average, before jumping. Dangling pages force extra jumps, so on a web that has them the mean is smaller.
The symbols $d$ and $\alpha$. This article writes $d$ for the probability of following a link, as Brin and Page do. The course text (Manning, Raghavan, and Schütze, 2008, §21.2) uses the opposite parameter: its $\alpha$ is the probability of teleporting, so
$$\alpha = 1 - d, \qquad d = 0.85 \iff \alpha = 0.15.$$
Every formula here turns into the course text's by replacing $d$ with $1 - \alpha$ and $1 - d$ with $\alpha$. The course text suggests $\alpha$ "might be 0.1", which is $d = 0.9$. Other authors use the same letter the other way: Langville and Meyer (2006) write $\alpha$ for the damping factor itself, and Haveliwala and Kamvar (2003) write $c$. The symbol must be checked in each source before a number is compared.
The next section turns the thought experiment into a formula.
The formula
Here is the idea in one sentence: a page is important if important pages link to it, and each page's vote is split equally among the pages it links to. The PageRank of page $p$ is the probability of being there:
$$PR(p) = \frac{1 - d}{N} + d \sum_{q \to p} \frac{PR(q)}{L(q)},$$
where the sum is over pages $q$ that link to $p$ and $L(q)$ is the number of out-links of $q$. Each page divides its PageRank equally among the pages it links to, and every page also receives an equal share of the teleportation. The PageRanks of all pages sum to 1. Brin and Page's paper wrote the first term as $1 - d$, without dividing by $N$, while also stating that the PageRanks sum to 1. With that first term they sum to $N$ instead, which scales every value by $N$ but gives the same ranking.
The formula as written assumes every page has at least one out-link. A dangling page sends the surfer to a random page, so its PageRank is spread evenly over all $N$ pages, adding $d \sum_{q \text{ dangling}} PR(q)/N$ to every page.
The formula defines each page's PageRank in terms of the PageRanks of the pages that link to it. So it is not a recipe but a system of $N$ equations in $N$ unknowns. The rest of this article is about that system: how to write it compactly, why it has exactly one solution, and how to find it. First, though, we need a web small enough to write the system out in full.
The five-page example
A small web is used throughout. Page $A$ links to $B$ and $C$, $B$ links to $C$ and $E$, $C$ links to $A$, and $D$ links to $C$. Page $E$ has no out-links, so it is dangling, and nothing links to $D$. Two of the difficulties PageRank has to handle on the real web appear here in miniature: a page that no link reaches, and a page that leads nowhere. The cycle $A \to C \to A$ makes the computation swing before it settles. A third difficulty, a group of pages that traps the surfer, gets its own tiny example below.
Example (one in-link beats three). $C$ has three in-links and $A$ has one, from $C$, yet $A$ has the higher PageRank, though narrowly: the solution below gives $0.3171$ for $A$ and $0.3113$ for $C$. $C$ collects rank from three pages, but it gives all of its own rank to $A$, while the pages linking to $C$ split theirs. What counts is how important the linking pages are and how many other pages share their votes.
The equations, written out
With $N = 5$ and $d = 0.85$, every page receives $0.15/5 = 0.03$ from teleportation and $0.85/5 = 0.17$ of $E$'s PageRank from the dangling page. Call that common part $t = 0.03 + 0.17\,\pi_E$, writing $\pi_p$ for the PageRank of page $p$. A page with two out-links passes $0.85/2 = 0.425$ of its rank along each, and a page with one out-link passes $0.85$. The formula then gives one equation per page:
$$\begin{aligned} \pi_A &= t + 0.85\,\pi_C, \\ \pi_B &= t + 0.425\,\pi_A, \\ \pi_C &= t + 0.425\,\pi_A + 0.425\,\pi_B + 0.85\,\pi_D, \\ \pi_D &= t, \\ \pi_E &= t + 0.425\,\pi_B. \end{aligned}$$
Five equations of this kind are small enough to solve by hand. Since $\pi_D = t$, measure everything in units of $t$ and substitute downward. The second equation gives $\pi_B = t + 0.425\,\pi_A$. Putting that into the fifth gives $\pi_E = 1.425\,t + 0.180625\,\pi_A$, and into the third, $\pi_C = 2.275\,t + 0.605625\,\pi_A$. The first equation then reads $\pi_A = 2.93375\,t + 0.51478\,\pi_A$, so $\pi_A = 6.0462\,t$, and back-substitution gives
$$(\pi_A, \pi_B, \pi_C, \pi_D, \pi_E) = t\,(6.0462,\ 3.5697,\ 5.9368,\ 1,\ 2.5171).$$
The values must sum to 1, and the bracket sums to $19.0698$, so $t = 1/19.0698 = 0.0524$. As a check, $0.03 + 0.17\,\pi_E = 0.03 + 0.17 \times 2.5171 \times 0.0524 = 0.0524$, which is $t$ again. The equations fix the PageRanks only up to a common scale until the sum is imposed. This is the first sign that PageRank is an eigenvector, which is defined only up to scale.
| Page | PageRank, $d = 0.85$ | Without teleportation |
|---|---|---|
| A | 0.3171 | 0.3415 (14/41) |
| B | 0.1872 | 0.1951 (8/41) |
| C | 0.3113 | 0.3171 (13/41) |
| D | 0.0524 | 0.0244 (1/41) |
| E | 0.1320 | 0.1220 (5/41) |
Values are rounded to four decimals. The column without teleportation sets $d = 1$, keeping only the repair of the dangling page, and its exact fractions come from solving the same equations in rational arithmetic.
So, as stated above, $A$ ranks highest even though it has a single in-link, from $C$. A link from an important page that links to little else is worth a great deal. $D$, which nothing links to, still gets $0.0524$: $0.03$ from teleportation and $0.17 \times 0.1320 = 0.0224$ from the dangling page $E$, whose surfer jumps to a random page.
Where the rank flows
These numbers balance at every page, as following the rank along each link shows. At the PageRank vector, the rank sent along each link is $d\,\pi_q / L(q)$.
- $C$ sends $0.85 \times 0.3113 = 0.2646$ to $A$.
- $A$ sends $0.1348$ to each of $B$ and $C$.
- $B$ sends $0.0796$ to each of $C$ and $E$.
- $D$ sends $0.0446$ to $C$.
- $E$ sends $0.0224$ to every page, and teleportation adds $0.03$ to every page.
$A$'s PageRank is then $0.03 + 0.0224 + 0.2646 = 0.3170$, which is $0.3171$ before the parts are rounded. The other pages add up the same way. The balance holds at every page at once, which is what it means for the distribution to be stationary.
What goes wrong without the fixes
The five-page solution used two fixes: $E$'s rank was spread over every page, and the surfer sometimes jumped. Were they needed? Teleportation and the repair of dangling pages are not refinements. Without them the computation fails, in two different ways. Both show up on tiny graphs.
A dangling page leaks rank. In the left web, $X$ links to $Y$ and $Z$, $Y$ links to $Z$, and $Z$ links nowhere. Start the surfer uniformly and move the probability along the links, as the formula does with $d = 1$:
| Step $k$ | X | Y | Z | Total |
|---|---|---|---|---|
| 0 | 0.333 | 0.333 | 0.333 | 1.000 |
| 1 | 0 | 0.167 | 0.500 | 0.667 |
| 2 | 0 | 0 | 0.167 | 0.167 |
| 3 | 0 | 0 | 0 | 0 |
Probability that reaches $Z$ has nowhere to go, so it disappears. The five-page example leaks the same way through $E$, only more slowly. Following its links only, the total probability falls from 1 to $0.80$ after one step, $0.70$ after two, $0.28$ after ten and $0.024$ after thirty. The total shrinks by a factor approaching $0.885$ per step, a number that reappears below as an eigenvalue. Sending a dangling page's rank to every page stops the leak. With that repair the left web has PageRanks $(0.182, 0.273, 0.545)$ without teleportation and $(0.198, 0.282, 0.521)$ with it.
A spider trap absorbs rank. In the right web, $X$ and $Y$ link to each other, $Y$ also links to $Z$, and $Z$ and $W$ link only to each other. Nothing is dangling, so no rank leaks, but once probability enters $\{Z, W\}$ it never leaves:
| Step $k$ | X | Y | Z | W | In the trap |
|---|---|---|---|---|---|
| 0 | 0.250 | 0.250 | 0.250 | 0.250 | 0.500 |
| 1 | 0.125 | 0.250 | 0.375 | 0.250 | 0.625 |
| 2 | 0.125 | 0.125 | 0.375 | 0.375 | 0.750 |
| 5 | 0.031 | 0.062 | 0.469 | 0.438 | 0.906 |
| 10 | 0.008 | 0.008 | 0.492 | 0.492 | 0.984 |
| 20 | 0.000 | 0.000 | 0.500 | 0.500 | 1.000 |
The trap ends up with everything. $X$ and $Y$, which link to each other and point a link into the trap, end with nothing: their combined share at step 20 is $0.0005$ and falling. Teleportation lets the surfer escape, but it undoes the trap only in part.
Example (how far teleportation undoes a trap). With $d = 0.85$, every step sends 15 percent of the probability to a page chosen at random, and half of those jumps land outside the trap. That does not cut the trap's share back to about one half, its share of the pages. With $d = 0.85$ the PageRanks are $(0.084, 0.109, 0.416, 0.391)$: the trap still holds $0.81$ of the rank, but $X$ and $Y$ keep a share. Teleportation limits what a trap can collect without removing its advantage, which is why link spammers build such structures (see Limits).
A web with two separate traps adds a third failure. The long-run answer depends on where the surfer starts, because a surfer who falls into one trap never sees the other. And two pages that link only to each other send a surfer who starts on the first to the second, then back, forever. Its distribution alternates between $(1, 0)$ and $(0, 1)$ and never settles. The matrix view below turns each failure into a statement about eigenvalues.
From links to the Google matrix
Number the pages $1$ to $N$ (here $A$ to $E$). The construction has three stages. Here is the plan: each stage is a matrix whose row $q$ says where a surfer on page $q$ goes next. The first follows links only, the second adds the dangling repair, and the third adds teleportation.
Stage 1: the link matrix $H$
The hyperlink matrix $H$ has one row for each page:
$$H_{qp} = \begin{cases} 1/L(q) & \text{if } q \text{ links to } p, \\ 0 & \text{otherwise.} \end{cases}$$
Row $q$ gives the probabilities of moving from page $q$ to each page by following a link. For the example, with rows and columns in the order $A, B, C, D, E$:
$$H = \begin{pmatrix} 0 & 1/2 & 1/2 & 0 & 0 \\ 0 & 0 & 1/2 & 0 & 1/2 \\ 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 \end{pmatrix}.$$
Let $\pi^{(k)}$ be a row vector giving the probability of the surfer being at each page after $k$ steps. Following one link turns it into $\pi^{(k)} H$. Entry $p$ of the product is $\sum_q \pi^{(k)}_q H_{qp}$, the probability arriving at $p$ from every page that links to it. This is the formula of the previous section with $d = 1$ and no dangling term. The rows of $H$ sum to 1 except the last, which is all zeros because $E$ is dangling. That zero row is the leak: each step loses the probability that was at $E$.
Stage 2: the stochastic matrix $S$
Replace each zero row with the uniform row $(1/N, \dots, 1/N)$. With $a$ the column vector that has a 1 for each dangling page and 0 elsewhere, here $a = (0, 0, 0, 0, 1)^{\mathsf{T}}$,
$$S = H + \frac{1}{N} a \mathbf{1}^{\mathsf{T}} = \begin{pmatrix} 0 & 1/2 & 1/2 & 0 & 0 \\ 0 & 0 & 1/2 & 0 & 1/2 \\ 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 1/5 & 1/5 & 1/5 & 1/5 & 1/5 \end{pmatrix},$$
where $\mathbf{1}$ is the column vector of $N$ ones. Every entry of $S$ is nonnegative and every row sums to 1, which makes $S$ a (row-)stochastic matrix: each row is a probability distribution over the next page. Total probability is now conserved, since $\pi S \mathbf{1} = \pi \mathbf{1} = 1$.
Stage 3: the Google matrix $G$
Teleportation mixes $S$ with the matrix whose entries are all $1/N$:
$$G = dS + \frac{1 - d}{N} \mathbf{1}\mathbf{1}^{\mathsf{T}}.$$
With $d = 0.85$, every entry of $S$ is multiplied by $0.85$ and then increased by $0.15/5 = 0.03$. An entry of $1/2$ becomes $0.455$, an entry of $1$ becomes $0.88$, a zero becomes $0.03$, and the dangling row's $1/5$ becomes $0.17 + 0.03 = 0.2$:
$$G = \begin{pmatrix} 0.03 & 0.455 & 0.455 & 0.03 & 0.03 \\ 0.03 & 0.03 & 0.455 & 0.03 & 0.455 \\ 0.88 & 0.03 & 0.03 & 0.03 & 0.03 \\ 0.03 & 0.03 & 0.88 & 0.03 & 0.03 \\ 0.2 & 0.2 & 0.2 & 0.2 & 0.2 \end{pmatrix}.$$
Every row still sums to 1 (for the first, $0.03 \times 3 + 0.455 \times 2 = 1$), so $G$ is stochastic too, and now every entry is positive. One step of the full random surfer turns $\pi$ into $\pi G$. PageRank is the distribution that a step leaves unchanged:
$$\pi = \pi G, \qquad \sum_p \pi_p = 1.$$
Written out for one page, $\pi = \pi G$ is exactly the formula with the dangling term, and for the example it is the five equations solved above. In the language of linear algebra, $\pi$ is a left eigenvector of $G$ with eigenvalue 1, which is the same as an ordinary (right) eigenvector of $G^{\mathsf{T}}$. In the language of probability, $G$ describes a Markov chain and $\pi$ is its stationary distribution (Manning, Raghavan, and Schütze, 2008, §21.2). The course text builds the same matrix in four steps, with its teleport probability $\alpha = 1 - d$: replace each zero row by $1/N$, divide each other row by its number of links, multiply by $1 - \alpha$, and add $\alpha/N$ to every entry. With $\alpha = 0.15$ the result is the matrix $G$ above, entry for entry.
Why there is exactly one answer
The equation $\pi = \pi G$ asks for an eigenvector. Such a vector exists, and once scaled to sum to 1 there is exactly one. Three things need showing:
- that the eigenvalue 1 exists;
- that there is an eigenvector for it with all entries positive;
- that this eigenvector is unique once scaled to sum to 1.
A fourth, that power iteration reaches it from any start, is shown in How fast it converges. The arguments below use only the definition of an eigenvalue and the triangle inequality.
A stochastic matrix has eigenvalue 1
Because every row of $G$ sums to 1, multiplying $G$ by the all-ones column vector gives it back: $G\mathbf{1} = \mathbf{1}$. So $\mathbf{1}$ is a right eigenvector with eigenvalue 1. A matrix and its transpose have the same characteristic polynomial, $\det(\lambda I - G) = \det(\lambda I - G^{\mathsf{T}})$, so they have the same eigenvalues, and 1 is also an eigenvalue of $G^{\mathsf{T}}$. There is therefore some nonzero row vector $\pi$ with $\pi G = \pi$. The same holds for $S$, but not for $H$, whose zero row breaks $H\mathbf{1} = \mathbf{1}$.
No eigenvalue is larger than 1 in modulus. Suppose $Gx = \lambda x$ with $x \ne 0$, and let $i$ be an index where $\lvert x_i \rvert$ is largest. Row $i$ of the equation gives
$$\lvert \lambda \rvert\, \lvert x_i \rvert = \Big\lvert \sum_j G_{ij} x_j \Big\rvert \le \sum_j G_{ij} \lvert x_j \rvert \le \sum_j G_{ij} \lvert x_i \rvert = \lvert x_i \rvert,$$
using the triangle inequality, then $\lvert x_j \rvert \le \lvert x_i \rvert$, then the row sum. Dividing by $\lvert x_i \rvert$ gives $\lvert \lambda \rvert \le 1$. This argument uses only that the entries are nonnegative and the rows sum to 1, so it holds for $S$ as well.
With positive entries, the eigenvector is unique and positive
The Perron–Frobenius theorem concerns matrices with all entries positive. Such a matrix has an eigenvalue of largest modulus that is real, positive, and simple, with an eigenvector whose entries are all positive. For a positive stochastic matrix such as $G$, the parts needed here follow in three short steps.
- Only $\lambda = 1$ lies on the unit circle, and its right eigenvectors are constant. If $\lvert \lambda \rvert = 1$ in the chain of inequalities above, both inequalities must be equalities. The second is an equality only if $\lvert x_j \rvert = \lvert x_i \rvert$ for every $j$, because every $G_{ij}$ is positive and so every term counts. The first is an equality only if all the numbers $G_{ij} x_j$ point in the same direction in the complex plane. Equal moduli and equal directions mean all $x_j$ are equal, so $x$ is a multiple of $\mathbf{1}$, and then $Gx = x$ gives $\lambda = 1$.
- The left eigenvector is unique up to scale. Step 1 shows that the solutions of $(G - I)x = 0$ form a one-dimensional space, so $G - I$ has rank $N - 1$. A matrix and its transpose have the same rank, so the solutions of $\pi (G - I) = 0$ also form a one-dimensional space. Every left eigenvector for eigenvalue 1 is a multiple of one vector, and requiring the entries to sum to 1 picks out one.
- That vector can be taken positive. Let $\pi G = \pi$. For each page $p$, $\lvert \pi_p \rvert = \lvert \sum_q \pi_q G_{qp} \rvert \le \sum_q \lvert \pi_q \rvert G_{qp}$. Summing over $p$, the left side gives $\sum_p \lvert \pi_p \rvert$ and the right side gives $\sum_q \lvert \pi_q \rvert \sum_p G_{qp} = \sum_q \lvert \pi_q \rvert$, the same total. So every one of the inequalities is an equality, which with all $G_{qp} > 0$ means the nonzero $\pi_q$ all have the same sign. Choose it positive. Then $\pi_p = \sum_q \pi_q G_{qp}$ is a sum of nonnegative terms with at least one positive, so every $\pi_p > 0$.
The argument needed every entry of $G$ to be positive. Teleportation guarantees this, since every entry is at least $(1 - d)/N > 0$: from any page the surfer can reach any other page in a single step. Without it, each failure from the tiny webs breaks one of the steps:
- Pages can be unreachable. Following links in $H$, nothing ever arrives at $D$, so a surfer who only follows links visits $D$ at most once, and its long-run share is 0. The positivity in step 3 fails.
- Rank can be trapped. If the graph contains two traps, there are infinitely many stationary distributions, one for each way of dividing the probability between them, and step 2 fails. In the language of Markov chains, such a chain has two irreducible closed subsets: sets of states that the chain never leaves and that contain no smaller such set. Haveliwala and Kamvar (2003, Theorem 3 in their appendix) quote a result of Isaacson and Madsen: the multiplicity of the eigenvalue 1 of a stochastic matrix equals the number of them.
- The walk can oscillate. For the two pages that only link to each other, the link matrix has eigenvalues $1$ and $-1$. The eigenvalue $-1$ is on the unit circle, step 1 fails, and the part of the distribution along its eigenvector flips sign every step and never decays.
In Markov chain terms, $G$ is irreducible: every page can reach every other. It is also aperiodic: the walk does not cycle with a fixed period. Such a chain has a unique stationary distribution that it approaches from any start. Manning, Raghavan, and Schütze (2008, §21.2.1, Theorem 21.1) state this for chains they call ergodic and draw the same conclusion for the walk with teleporting, without proof; Markov Chains and Stationary Distributions proves it for every finite chain (Theorems 3 and 6). This article does not rely on the general theorem. For $G$, uniqueness and positivity are proved in the three steps above, and convergence from any start is proved in How fast it converges.
The five-page example is, by luck, well behaved even without teleportation. The dangling repair gives $E$ a link to every page, including itself, and every page can reach $E$ (through $B$), so $S$ is irreducible, and the self-step makes it aperiodic. That is why the column "without teleportation" above has a unique answer. A web with a spider trap, which the dangling repair does not touch, has no such luck.
The eigenvalues of the example
The argument says that a positive stochastic matrix has the eigenvalue 1 and no other eigenvalue on the unit circle. This section computes the eigenvalues of the example and shows what teleportation does to them: it leaves the eigenvalue 1 in place and multiplies every other eigenvalue by $d$. The characteristic polynomial of $S$, computed in exact fractions, factors as
$$\det(\lambda I - S) = (\lambda - 1)\left(\lambda^4 + \tfrac{4}{5}\lambda^3 + \tfrac{1}{5}\lambda^2 + \tfrac{1}{20}\right).$$
The factor $\lambda - 1$ is the eigenvalue every stochastic matrix has. The quartic has two complex-conjugate pairs of roots. Rounded to four decimals, the eigenvalues of the three matrices are:
| Matrix | Eigenvalues | Moduli |
|---|---|---|
| $H$ | $0.8846$, $-0.4423 \pm 0.2949i$, $0$, $0$ | 0.8846, 0.5316, 0 |
| $S$ | $1$, $-0.5542 \pm 0.3417i$, $0.1542 \pm 0.3069i$ | 1, 0.6511, 0.3434 |
| $G$, $d = 0.85$ | $1$, $-0.4711 \pm 0.2904i$, $0.1311 \pm 0.2608i$ | 1, 0.5534, 0.2919 |
The largest eigenvalue of $H$ is $0.8846$, the real root of $\lambda^3 - \lambda/2 - 1/4$, and it is less than 1 because $H$ loses probability at $E$. This is the factor by which the total probability shrank per step in the leak described earlier. Repairing the dangling row lifts the top eigenvalue to exactly 1. Every other eigenvalue of $S$ lies strictly inside the unit circle, as expected for an irreducible, aperiodic chain.
Comparing the rows for $S$ and $G$ shows the pattern: apart from the eigenvalue 1, each eigenvalue of $G$ is exactly $0.85$ times an eigenvalue of $S$. For instance $0.85 \times (-0.5542 + 0.3417i) = -0.4711 + 0.2904i$, and $0.85 \times 0.6511 = 0.5534$.
Example (another damping factor). If the damping factor were $0.5$ instead of $0.85$, the modulus of the second eigenvalue of $G$ for the five-page web would be about $0.3255$, which is $0.5 \times 0.6511$. The eigenvalues of $S$ do not depend on $d$, so only the factor changes. With $d = 0.95$ it would be $0.6185$. This second modulus matters because it sets how fast power iteration converges, as How fast it converges shows.
Why every other eigenvalue shrinks by $d$
The pattern holds for every graph. Here is the idea. In a basis whose first vector is $\mathbf{1}$, teleportation changes only the first row of the matrix. Everything else in $G$ is then $d$ times the corresponding part of $S$.
The formal version. Let $v$ be the teleportation distribution, a column vector of nonnegative entries summing to 1 (uniform, $v = \mathbf{1}/N$, so far), so that $G = dS + (1-d)\mathbf{1}v^{\mathsf{T}}$. Choose any invertible matrix $Q$ whose first column is $\mathbf{1}$, and write $Q = (\mathbf{1} \mid X)$.
- Since $S\mathbf{1} = \mathbf{1}$, the first column of $Q^{-1} S Q$ is $Q^{-1}\mathbf{1}$, which is the first unit vector $e_1$ (because $Q e_1 = \mathbf{1}$). So $Q^{-1} S Q$ is block upper triangular, $\begin{pmatrix} 1 & b^{\mathsf{T}} \\ 0 & T \end{pmatrix}$ for some row $b^{\mathsf{T}}$ and $(N-1) \times (N-1)$ block $T$. Its eigenvalues, which are those of $S$, are 1 together with the eigenvalues $\lambda_2, \dots, \lambda_N$ of $T$.
- For the teleportation term, $Q^{-1}\mathbf{1}v^{\mathsf{T}}Q = e_1 (v^{\mathsf{T}}Q) = e_1 (v^{\mathsf{T}}\mathbf{1},\ v^{\mathsf{T}}X) = \begin{pmatrix} 1 & v^{\mathsf{T}}X \\ 0 & 0 \end{pmatrix}$, using $v^{\mathsf{T}}\mathbf{1} = 1$. All of it sits in the first row.
- Adding the two with weights $d$ and $1-d$, $$Q^{-1} G Q = \begin{pmatrix} 1 & d\,b^{\mathsf{T}} + (1-d)\,v^{\mathsf{T}}X \\ 0 & d\,T \end{pmatrix}.$$ The eigenvalues of $G$ are therefore 1 and $d\lambda_2, \dots, d\lambda_N$.
Since $S$ is stochastic, every $\lvert \lambda_i \rvert \le 1$, so every eigenvalue of $G$ other than the first has modulus at most $d$. Haveliwala and Kamvar (2003, Theorem 1) proved this bound, $\lvert \lambda_2(G) \rvert \le d$, for any stochastic $S$ and any teleportation distribution, by a different argument. They also proved (Theorem 2) that equality holds whenever the chain of $S$ has at least two irreducible closed subsets. The derivation above shows why: two such subsets make the eigenvalue 1 of $S$ appear twice, once in $T$, and $d$ times it is $d$. They point out that the web graph contains many such subsets, so on the real web $\lvert \lambda_2 \rvert = d$ exactly. The second panel of the convergence figure below is a small web where this happens.
The eigenvector, normalized
A numerical eigenvalue routine (numpy's eig applied to $G^{\mathsf{T}}$) returns the eigenvector for eigenvalue 1 scaled to unit Euclidean length:
$$x = (0.6308,\ 0.3724,\ 0.6194,\ 0.1043,\ 0.2626).$$
Any multiple of $x$ is an equally valid eigenvector, and a routine may as easily return $-x$. Dividing by the sum of the entries, $1.9895$, gives the probability vector
$$\pi = (0.3171,\ 0.1872,\ 0.3113,\ 0.0524,\ 0.1320),$$
the PageRank of the table above. Dividing $x$ by its fourth entry instead gives $(6.046, 3.570, 5.937, 1, 2.517)$, the vector in units of $t$ found by hand. The hand solution, the eigenvector routine and power iteration are three routes to the same vector.
Power iteration
How is the answer found when the web has billions of pages? For a matrix with billions of rows, solving the equations directly is out of the question. Power iteration applies the walk repeatedly instead. Start from the uniform distribution $\pi^{(0)} = (1/N, \dots, 1/N)$, and compute $\pi^{(k+1)} = \pi^{(k)} G$ until the values stop changing. The table traces it on the example. Its last column is the $L_1$ distance $\lVert \pi^{(k)} - \pi \rVert_1 = \sum_p \lvert \pi^{(k)}_p - \pi_p \rvert$ to the final answer:
| $k$ | A | B | C | D | E | Error |
|---|---|---|---|---|---|---|
| 0 | 0.2000 | 0.2000 | 0.2000 | 0.2000 | 0.2000 | 0.4568 |
| 1 | 0.2340 | 0.1490 | 0.4040 | 0.0640 | 0.1490 | 0.2425 |
| 2 | 0.3987 | 0.1548 | 0.2725 | 0.0553 | 0.1187 | 0.1691 |
| 3 | 0.2818 | 0.2196 | 0.3324 | 0.0502 | 0.1160 | 0.1071 |
| 4 | 0.3323 | 0.1695 | 0.3055 | 0.0497 | 0.1431 | 0.0526 |
| 5 | 0.3140 | 0.1955 | 0.3098 | 0.0543 | 0.1263 | 0.0205 |
| 6 | 0.3148 | 0.1849 | 0.3142 | 0.0515 | 0.1346 | 0.0109 |
| 8 | 0.3150 | 0.1883 | 0.3126 | 0.0523 | 0.1317 | 0.0049 |
| 40 | 0.3171 | 0.1872 | 0.3113 | 0.0524 | 0.1320 | $< 10^{-10}$ |
The first step can be checked by hand from $G$. Starting from $0.2$ everywhere, page $C$ receives $0.2 \times (0.455 + 0.455 + 0.03 + 0.88 + 0.2) = 0.404$, the sum of column $C$ of $G$ times $0.2$. $D$ receives $0.2 \times (0.03 \times 4 + 0.2) = 0.064$.
The early iterations swing back and forth as PageRank flows around the cycle from $A$ to $C$ and back. After step 1, $C$ holds $0.404$, collected from three in-links. At step 2 it passes almost all of that to $A$, which jumps to $0.399$ while $C$ falls. With the stopping rule that the total change in the five values falls below $10^{-10}$, the computation ended after 40 iterations.
$G$ is never formed in practice. It is dense, with $N^2$ entries, while $H$ is sparse, with one entry for each link. Because the dangling repair and the teleportation term each add the same amount to every page, each iteration can be computed from $H$ alone:
$$\pi^{(k+1)} = d\, \pi^{(k)} H + \frac{d\,\pi^{(k)} a + 1 - d}{N} \mathbf{1}^{\mathsf{T}},$$
where $\pi^{(k)} a$ is the total probability currently on dangling pages. This costs time proportional to the number of links. The computation runs over the link graph that a connectivity server stores, and it is done offline. PageRank does not depend on the query, so it is computed once for the collection and stored with each page.
How fast it converges
A short calculation shows that power iteration always converges and bounds how fast. Subtract $\pi = \pi G$ from $\pi^{(k+1)} = \pi^{(k)} G$ and expand $G$:
$$\pi^{(k+1)} - \pi = d\,(\pi^{(k)} - \pi)\,S + \frac{1-d}{N}\,\big((\pi^{(k)} - \pi)\mathbf{1}\big)\,\mathbf{1}^{\mathsf{T}}.$$
Both vectors sum to 1, so $(\pi^{(k)} - \pi)\mathbf{1} = 0$ and the teleportation term vanishes. Multiplying a row vector $e$ by a stochastic matrix cannot increase its $L_1$ norm, since $\sum_p \lvert \sum_q e_q S_{qp} \rvert \le \sum_q \lvert e_q \rvert \sum_p S_{qp} = \sum_q \lvert e_q \rvert$. Therefore
$$\lVert \pi^{(k+1)} - \pi \rVert_1 \le d\, \lVert \pi^{(k)} - \pi \rVert_1, \qquad \lVert \pi^{(k)} - \pi \rVert_1 \le d^k\, \lVert \pi^{(0)} - \pi \rVert_1.$$
The error shrinks by at least the factor $d$ at every step, from any starting distribution and on any graph. This also proves that the iteration converges to $\pi$ from every start, the fourth property promised above. With $d = 0.85$, reducing the error by a factor of $10^{10}$ takes at most $\ln 10^{-10} / \ln 0.85 \approx 142$ iterations, however large the web.
Example (40 iterations where the bound allows 142). The bound allows up to 142 iterations for a $10^{10}$ reduction at $d = 0.85$, and the five-page example stopped after 40. The bound is not wrong: it is a guarantee, not a prediction, and an iteration may beat it. Over many steps the error shrinks in proportion to $\lvert \lambda_2 \rvert^k$, where $\lambda_2$ is the eigenvalue of $G$ with the second-largest modulus.
The asymptotic rate, derived. Suppose $G$ has $N$ distinct eigenvalues $\lambda_1 = 1, \lambda_2, \dots, \lambda_N$, as the example does. Then $G$ can be diagonalized. Let $v_i$ be a right eigenvector for $\lambda_i$ (a column, $G v_i = \lambda_i v_i$) and $w_i$ a left eigenvector (a row, $w_i G = \lambda_i w_i$), scaled so that $w_i v_i = 1$. Left and right eigenvectors for different eigenvalues are orthogonal: $\lambda_i\, w_i v_j = (w_i G) v_j = w_i (G v_j) = \lambda_j\, w_i v_j$, so $w_i v_j = 0$ when $\lambda_i \ne \lambda_j$. The rows $w_i$ form a basis, so the start can be written $\pi^{(0)} = \sum_i c_i w_i$, and multiplying on the right by $v_j$ picks out $c_j = \pi^{(0)} v_j$. Each multiplication by $G$ multiplies the term along $w_i$ by $\lambda_i$:
$$\pi^{(k)} = \pi^{(0)} G^k = \sum_{i=1}^{N} c_i\, \lambda_i^k\, w_i.$$
The first term is $\pi$ itself. Indeed $v_1 = \mathbf{1}$, so $c_1 = \pi^{(0)}\mathbf{1} = 1$, and $w_1$ is the left eigenvector for eigenvalue 1 with $w_1 \mathbf{1} = 1$, which is $\pi$. Therefore
$$\pi^{(k)} - \pi = \sum_{i=2}^{N} c_i\, \lambda_i^k\, w_i,$$
a sum of terms that shrink like $\lvert \lambda_i \rvert^k$. The slowest, with $\lvert \lambda_2 \rvert$, sets the pace, unless the start happens to have $c_2 = 0$. The script checks this expansion against the iterates of the example at $k = 0, 1, 5$ and $20$. When eigenvalues repeat, $G$ may not be diagonalizable, and the term for $\lambda_2$ can carry an extra polynomial factor in $k$. The rate is then still $\lvert \lambda_2 \rvert^k$ up to that factor (Langville and Meyer, 2006).
For the example $\lvert \lambda_2 \rvert = 0.85 \times 0.6511 = 0.5534$, and a reduction by $10^{10}$ needs about $\ln 10^{-10} / \ln 0.5534 \approx 39$ iterations, close to the 40 observed. $\lambda_2$ is complex, and complex eigenvalues make the error rotate as it shrinks, which appears as values that overshoot and come back. The rotation also makes the error fall unevenly. In the table, the ratio of successive errors varies between $0.39$ and $0.73$ in the first eight steps, while its long-run geometric average is $0.5534$.
The bound itself can be reached. On some webs it is, as the right panel of the next figure shows.
On the two-trap web, $S$ has eigenvalues $1, 1, -1, -1, 0$, and $G$ has $1, d, -d, -d, 0$. Real web graphs are like the right panel, since they contain many traps. So the asymptotic rate of PageRank's convergence on the web is $d$ exactly, independent of the size of the graph (Haveliwala and Kamvar, 2003, §5).
The bound also shows the cost of a damping factor close to 1. Raising $d$ gives the link structure more weight relative to teleportation, but it has two costs. It slows convergence, and it makes the result more sensitive to small changes in the graph and to groups of pages that trap rank (Langville and Meyer, 2006). Haveliwala and Kamvar (2003) connect the second point to the eigenvalues as well: the gap between 1 and $\lvert \lambda_2 \rvert$ governs how stable the stationary distribution is under perturbation of the chain.
The random surfer as a Markov chain
Does the matrix still describe the surfer? It does: the algebra and the thought experiment describe the same object. $G_{qp}$ is the probability that a surfer on page $q$ is on page $p$ one step later. By the rules of probability, the entries of $G^k$ are the probabilities of going from $q$ to $p$ in exactly $k$ steps. A surfer whose position is uncertain, with distribution $\pi^{(0)}$, has distribution $\pi^{(0)} G^k$ after $k$ steps. Power iteration is literally the evolution of the surfer's probability distribution, one click at a time.
Example (two clicks from $D$). A surfer who starts on $D$ for certain is most likely to be on $A$ two clicks later, with probability $0.783$. Row $D$ of $G$ is $(0.03, 0.03, 0.88, 0.03, 0.03)$, since a surfer on $D$ almost certainly moves to $C$. Row $D$ of $G^2$ is $(0.783, 0.048, 0.086, 0.035, 0.048)$, since from $C$ the surfer almost certainly moves on to $A$.
The start still matters after two clicks. Does it ever stop mattering? Because power iteration converges to $\pi$ from every start, every row of $G^k$ approaches $\pi$. By $G^{10}$, row $D$ is $(0.315, 0.190, 0.312, 0.053, 0.130)$. The largest difference between any entry of $G^k$ and the corresponding entry of $\pi$ is $0.57$ for $k = 1$, $0.046$ for $k = 5$, $0.0029$ for $k = 10$, and $9 \times 10^{-6}$ for $k = 20$.
The definition at the start of this article was the long-run fraction of time spent on a page, not a probability at one moment. The ergodic theorem for Markov chains says that for an irreducible chain the two agree. The fraction of the first $n$ steps that a single surfer spends on page $p$ converges to $\pi_p$ as $n$ grows, with probability 1. The theorem is not proved here. It is Theorem 21.1 of the course text, stated there without proof, and it is proved for irreducible chains in Norris's textbook (1997, §1.10, Theorem 1.10.2), under the name ergodic theorem. The article's own results do not depend on it: they concern the distribution $\pi^{(k)}$, not the path of one surfer. The theorem's claim can be checked on the example by simulation. A surfer followed the rules for 100,000 steps on the example, and the run was repeated 30 times with different random seeds. It spent the following fractions of its time on each page (median over the 30 runs, with the interquartile range):
| Page | Simulated share, median (IQR) | PageRank |
|---|---|---|
| A | 0.3173 (0.3170 to 0.3177) | 0.3171 |
| B | 0.1870 (0.1867 to 0.1874) | 0.1872 |
| C | 0.3113 (0.3109 to 0.3119) | 0.3113 |
| D | 0.0524 (0.0521 to 0.0527) | 0.0524 |
| E | 0.1318 (0.1313 to 0.1327) | 0.1320 |
The simulated surfer agrees with the eigenvector to within the run-to-run variation. Simulation is a poor way to compute PageRank, since its error falls only as the inverse square root of the number of steps. But it confirms that the eigenvector means what the thought experiment says. Markov chain Monte Carlo runs the same argument in reverse: it builds a chain whose stationary distribution is a posterior distribution, and estimates posterior averages by averages along one simulated path (Markov Chain Monte Carlo).
PageRank as a linear system
For a small graph, $\pi$ can be solved for directly, as we did by hand at the start. Because $\pi$ sums to 1, the teleportation term $\pi \frac{1-d}{N} \mathbf{1}\mathbf{1}^{\mathsf{T}}$ equals $\frac{1-d}{N}\mathbf{1}^{\mathsf{T}}$, and the eigenvector equation becomes a linear system:
$$\pi (I - dS) = \frac{1 - d}{N} \mathbf{1}^{\mathsf{T}}.$$
The matrix $I - dS$ is always invertible, since every eigenvalue of $dS$ has modulus at most $d < 1$, so $I - dS$ cannot have eigenvalue 0.
Example (no inverse without teleportation). Without teleportation ($d = 1$), the same idea would give $\pi (I - S) = 0$, and that system cannot be solved by inverting $I - S$. $S\mathbf{1} = \mathbf{1}$ gives $(I - S)\mathbf{1} = 0$, so $I - S$ is never invertible. The equation then fixes $\pi$ at best up to scale, as the hand solution's factor $t$ was, and the sum condition must be added separately. With $d < 1$ it is built into the right-hand side.
Solving the system for the example gives the same values as power iteration. Solving it in exact rational arithmetic gives $\pi_A = 1877600/5921921$, with the same denominator for the other four. For a small graph this is the simplest way to compute PageRank exactly. The five equations solved by hand at the start are this system written out.
The system can also be written with the sparse $H$ in place of $S$. Solving $x (I - dH) = \frac{1}{N}\mathbf{1}^{\mathsf{T}}$ and dividing $x$ by the sum of its entries gives the same $\pi$. The dangling term only adds a multiple of $\mathbf{1}^{\mathsf{T}}$ to the right-hand side, and the final normalization absorbs it.
Expanding the inverse as a series, $(I - dS)^{-1} = I + dS + d^2S^2 + \cdots$, gives an interpretation:
$$\pi = \frac{1 - d}{N} \sum_{k=0}^{\infty} d^k\, \mathbf{1}^{\mathsf{T}} S^k.$$
The surfer lands on a random page, then follows $k$ links before the next jump, with probability $(1-d)d^k$. A page's PageRank adds up all the paths that end at it, with paths of length $k$ discounted by $d^k$. Long chains of links count, but less than short ones. Power iteration computes this sum one term at a time.
Personalized PageRank
The surfer so far jumps to every page alike. If the jumps favor some pages, the same construction gives importance as seen from those pages. Nothing requires the surfer to teleport uniformly, and Page, Brin, Motwani, and Winograd (1999, §6) already proposed biasing the jump. Replacing the uniform jump with a probability vector $v$ over pages, and sending the surfer from a dangling page according to $v$ as well, gives
$$G_v = d\,(H + a v^{\mathsf{T}}) + (1 - d)\, \mathbf{1} v^{\mathsf{T}}, \qquad \pi \propto v^{\mathsf{T}} (I - dH)^{-1}.$$
The second form follows as in the previous section: $\pi = \pi G_v$ gives $\pi (I - dH) = (d\,\pi a + 1 - d)\, v^{\mathsf{T}}$, a scalar times $v^{\mathsf{T}}$, and normalizing removes the scalar. The surfer now always restarts from pages favored by $v$, and PageRank measures importance as seen from those pages. In the example, teleporting only to $A$ gives $(0.452, 0.192, 0.274, 0, 0.082)$. $A$ rises, and $D$, which no path from $A$ reaches, falls to zero.
Example (teleporting only to $D$). Now every jump lands on $D$, and a surfer on a page with links jumps with probability $1 - d = 0.15$. $D$'s PageRank comes out above $0.15$: teleporting only to $D$ gives $(0.290, 0.123, 0.341, 0.194, 0.052)$. $D$ holds more than the $0.15$ that the jumps deliver to it, because the surfer who reaches the dangling page $E$ is also sent back to $D$. Some implementations keep the uniform jump for dangling pages while personalizing the rest, which gives slightly different numbers.
Haveliwala (2002) used this to compute topic-sensitive PageRank. Each of a set of broad topics gets its own PageRank vector, which teleports only to pages known to belong to that topic. At query time the vectors are combined according to how well the query matches each topic. With $v$ concentrated on a single page, personalized PageRank measures how closely every other page is connected to that one. The eigenvalue analysis above holds for any $v$ (with $H + a v^{\mathsf{T}}$ in the role of $S$), so the convergence bound $d^k$ applies to personalized PageRank too.
Why vectors can be combined
Combining precomputed vectors at query time works because personalized PageRank is linear in $v$. Here is the precise statement. Keep the dangling rows fixed, so that $S$ does not depend on $v$ (a dangling page sends the surfer to a uniformly random page whatever $v$ is; this is a choice made here, since in the course text's topic-specific walk a dangling page invokes the topic's own teleport), and let only the teleport step follow $v$: $G_v = dS + (1-d)\mathbf{1}v^{\mathsf{T}}$. The stationary vector satisfies $\pi_v = \pi_v G_v = d\,\pi_v S + (1-d)(\pi_v \mathbf{1})\,v^{\mathsf{T}}$, and $\pi_v \mathbf{1} = 1$, so
$$\pi_v (I - dS) = (1-d)\,v^{\mathsf{T}}, \qquad \pi_v = (1-d)\,v^{\mathsf{T}}(I - dS)^{-1}.$$
The right-hand side is a fixed matrix applied to $v$. So for teleport distributions $s$ and $p$ and any $q$ between 0 and 1,
$$\pi_{qs + (1-q)p} = q\,\pi_s + (1-q)\,\pi_p.$$
This is the result of Exercises 21.16 to 21.18 of the course text, which uses it to build a user's vector from topic vectors. It holds exactly under the fixed convention above, and also on any graph with no dangling page, where the two conventions are the same walk. Under the course text's own walk on a graph that has dangling pages it is not exact, as the example after this paragraph shows. Jeh and Widom (2003, §3) state the same fact as their Linearity Theorem and build personalized vectors from single-page vectors, which they call basis vectors. On the example, with fixed dangling rows, teleporting only to $A$ gives $(0.409, 0.191, 0.286, 0.017, 0.098)$ and only to $D$ gives $(0.296, 0.138, 0.334, 0.162, 0.071)$. Teleporting to $A$ with probability 0.6 and to $D$ with 0.4 gives $(0.364, 0.169, 0.305, 0.075, 0.087)$, which is 0.6 times the first plus 0.4 times the second. Averaging the five single-page vectors gives back the ordinary PageRank.
Example (a common misstatement). "Personalized PageRank is linear in $v$" is exact only under that convention, or when no page is dangling. Under the convention used earlier in this section, which is also the course text's, dangling pages jump according to $v$ as well. Then the matrix in the role of $S$ changes with $v$, and only the unnormalized vector $v^{\mathsf{T}}(I - dH)^{-1}$ is linear. On the example the 60/40 teleport then gives $(0.3824, 0.1625, 0.3025, 0.0835, 0.0691)$, while 0.6 and 0.4 times the two single-page vectors give $(0.3872, 0.1645, 0.3006, 0.0778, 0.0699)$. The true vector is still a mixture of the two, with weights $0.571$ and $0.429$ in place of 0.6 and 0.4, because the two unnormalized vectors have different sums.
Personalized PageRank has outlived web search as a way to rank the nodes of a graph by closeness to a set of seeds. One recent retrieval system for language models, HippoRAG (Gutiérrez, Shu, Gu, Yasunaga, and Su, 2024), runs it over a graph of entities extracted from a document collection, seeded at the entities named in the question. Entity linking has a similar use: Entity Linking describes a method that runs a random walk, similar to topic-sensitive PageRank, over a graph of mentions and candidate entities.
HITS
PageRank gives each page a single score, the same for every query. Kleinberg (1999) proposed a related method, HITS (hyperlink-induced topic search), which gives each page two scores. A good authority is linked to by many good hubs, and a good hub links to many good authorities. HITS: Hubs and Authorities treats the method in full: the query-time subgraph it runs on, the proof that its iteration converges, a worked example, and its comparison with PageRank. This section keeps only what the comparison on the five-page web needs.
Let $M$ be the adjacency matrix of the graph, with $M_{qp} = 1$ if $q$ links to $p$ (the letter $A$ already names a page here). The authority scores $x$ and hub scores $y$ satisfy
$$x \propto M^{\mathsf{T}} y, \qquad y \propto M x.$$
Alternating the two updates, and rescaling after each, is power iteration on $M^{\mathsf{T}}M$ for the authorities and on $MM^{\mathsf{T}}$ for the hubs. Started from all ones, it converges to an eigenvector of each matrix for its largest eigenvalue, as the HITS article proves. There is no teleportation and no damping factor.
Example (HITS on the five-page web). PageRank placed $A$ first on the five-page web, but HITS gives $A$ no authority at all. The authority scores, scaled to sum to 1, converge to $1/\sqrt{3} \approx 0.577$ for $C$, $(3 - \sqrt{3})/6 \approx 0.211$ each for $B$ and $E$, and 0 for $A$ and $D$. The hub scores are $(\sqrt{3} - 1)/2 \approx 0.366$ each for $A$ and $B$, $2 - \sqrt{3} \approx 0.268$ for $D$, and 0 for $C$ and $E$. $C$ is the authority, linked from three hubs.
$A$ gets nothing because its only in-link comes from $C$, and $C$ links to nothing else, so no page that links to $A$ also links to $B$, $C$ or $E$. In $M^{\mathsf{T}}M$, whose $(p, p')$ entry counts the pages linking to both $p$ and $p'$, page $A$ forms a separate block with eigenvalue 1, while the block for $B$, $C$ and $E$,
$$\begin{pmatrix} 1 & 1 & 0 \\ 1 & 3 & 1 \\ 0 & 1 & 1 \end{pmatrix},$$
has eigenvalues $2 + \sqrt{3} \approx 3.73$, $1$ and $2 - \sqrt{3}$. The principal eigenvector, proportional to $(1, 1 + \sqrt{3}, 1)$ on that block, lies entirely in the larger block. Kleinberg (1999, §6) describes the method as finding the most densely linked collection of hubs and authorities in the graph. Lempel and Moran (2000, §5.1) named the resulting bias toward small, densely linked groups the tightly knit community effect.
HITS was designed to run on a small subgraph around the results of a query, so its scores are query-dependent. That makes them more specific to the topic than PageRank's, but requires computation at query time (Manning, Raghavan, and Schütze, 2008, §21.3).
Both methods read importance from links. The next section sets out how far that evidence can be trusted.
Limits
PageRank measures popularity among link authors, which is not the same as relevance or quality. It is computed without regard to the query, so it can only reorder pages that text matching has already found. Its value also drew manipulation. Link farms, networks of pages that link to each other and to a target, and purchased links inflate a page's PageRank. The spider-trap example shows the mechanism: a closed group of pages kept $0.81$ of the rank in a four-page web even with teleportation. Haveliwala and Kamvar (2003) observe that each pair of such closed structures gives $G$ an eigenvector with eigenvalue $d$. They suggest that these eigenvectors may help in detecting link spam. Search engines introduced the rel="nofollow" link attribute in 2005 as a means of fighting comment spam (Google Search Central, 2019), so that links a site does not vouch for could be excluded, and developed methods to detect link spam. Google at first did not count a link marked this way at all, and since 2019 has treated the attribute as a hint (same source). In web search, PageRank is one of many signals. The course text describes a composite score that combines hundreds of features, among them cosine similarity, term proximity and PageRank, with weights set by machine learning (Manning, Raghavan, and Schütze, 2008, §21.2). It also treats every link alike; Knowledge Graphs gives each edge a named relation and queries the site's own link graph by pattern.
Every number in this article is computed by tools/experiments/crawling/pagerank_math.py in the site repository, and the figures by tools/figures/pagerank.py.
Worked problems
These are Exercises 21.6, 21.8, 21.9, 21.10 and 21.18 of the course text (Manning, Raghavan, and Schütze, 2008), restated in our words. The course text states them with its teleport probability $\alpha$; each solution says which $d = 1 - \alpha$ that is. The numbers are checked in pagerank_math.py.
Problem 1 (Exercise 21.6). A web graph has three nodes and the links $1 \to 2$, $3 \to 2$, $2 \to 1$ and $2 \to 3$. Write the transition matrix of the surfer's walk with teleporting for $\alpha = 0$, $\alpha = 0.5$ and $\alpha = 1$. We also find the steady state for $\alpha = 0.5$, which the exercise does not ask for and the course text works out in its §21.2.2 (Equations 21.4 and 21.5 and Figure 21.3).
No page is dangling, so $S = H$. Node 1 has one out-link, to 2. Node 2 has two, to 1 and 3. Node 3 has one, to 2:
$$S = \begin{pmatrix} 0 & 1 & 0 \\ 1/2 & 0 & 1/2 \\ 0 & 1 & 0 \end{pmatrix}.$$
The transition matrix is $P = (1 - \alpha)S + \frac{\alpha}{3}\mathbf{1}\mathbf{1}^{\mathsf{T}}$, which is $G$ with $d = 1 - \alpha$.
(a) $\alpha = 0$ ($d = 1$): $P = S$, the walk without teleporting.
(b) $\alpha = 0.5$ ($d = 0.5$): every entry of $S$ is halved and $0.5/3 = 1/6$ is added. An entry of 1 becomes $1/2 + 1/6 = 2/3$, an entry of $1/2$ becomes $1/4 + 1/6 = 5/12$, and a zero becomes $1/6$:
$$P = \begin{pmatrix} 1/6 & 2/3 & 1/6 \\ 5/12 & 1/6 & 5/12 \\ 1/6 & 2/3 & 1/6 \end{pmatrix}.$$
(c) $\alpha = 1$ ($d = 0$): every entry is $1/3$. The surfer ignores the links.
For the steady state in (b), nodes 1 and 3 have identical rows and identical columns, so exchanging them leaves $P$ unchanged. The steady state is unique, so it must be unchanged by the exchange too, and has the form $(p,\ 1 - 2p,\ p)$. The first component of $\pi = \pi P$ reads
$$p = \tfrac{1}{6}p + \tfrac{5}{12}(1 - 2p) + \tfrac{1}{6}p = \tfrac{5}{12} - \tfrac{1}{2}p, \qquad \text{so} \qquad p = \tfrac{5}{18}.$$
The steady state is $(5/18,\ 4/9,\ 5/18)$. Power iteration from $(1, 0, 0)$ gives $(1/6, 2/3, 1/6)$, $(1/3, 1/3, 1/3)$, $(1/4, 1/2, 1/4)$, $(7/24, 5/12, 7/24)$ and so on toward it, as in the course text's Figure 21.3. In case (a) the same start never settles: it alternates between $(0, 1, 0)$ and $(1/2, 0, 1/2)$, because without teleporting the walk has period 2. In case (c) every start reaches $(1/3, 1/3, 1/3)$ in one step.
Problem 2 (Exercise 21.8). A Markov chain has states $A$, $B$ and $C$. From $A$ the next state is $B$. From $B$ it is $A$ with probability $p_A$ and $C$ with probability $1 - p_A$. From $C$ it is $A$. For which values of $p_A$ in $[0, 1]$ is the chain ergodic?
It is ergodic exactly for $0 < p_A < 1$. The course text calls a chain ergodic if there is a time $T_0$ after which every state can be reached from every state at every later time, that is, every entry of $P^t$ is positive for all $t > T_0$.
- $p_A = 1$. The chain alternates $A, B, A, B, \dots$ and never reaches $C$ from $A$ or $B$. It is not ergodic.
- $p_A = 0$. The chain cycles $A \to B \to C \to A$. Started in $A$, it is in $A$ only at times that are multiples of 3, so no $T_0$ exists. It is not ergodic.
- $0 < p_A < 1$. Every state reaches every other, and there are two cycles through $A$: $A \to B \to A$ of length 2 and $A \to B \to C \to A$ of length 3. Since $5 = 2 + 3$, the chain can return to $A$ after 2, 3, 4 ($2 + 2$), 5, 6 ($3 + 3$) steps, and after every number of steps from 2 on, because every integer $t \ge 2$ is a sum of 2s and 3s. Any state reaches $A$ in at most 2 steps and $A$ reaches any state in at most 2 steps. So for every $t \ge 6$, a path of exactly $t$ steps joins any state to any other: go to $A$, circle back to $A$ for the right number of steps, and go on. The script confirms that for $p_A = 0.2$, $0.5$ and $0.9$ every entry of $P^t$ is positive from $t = 5$ on, and that no power is positive for $p_A = 0$ or $1$. The argument gives $t \ge 6$, and $t = 5$ in fact already suffices.
For $0 < p_A < 1$ the steady state solves $\pi_B = \pi_A$ and $\pi_C = (1 - p_A)\pi_B$, giving $\pi = (1, 1, 1 - p_A)/(3 - p_A)$, which is $(0.4, 0.4, 0.2)$ for $p_A = 0.5$.
Problem 3 (Exercise 21.9). Show that for any directed graph, the Markov chain of the random walk with teleporting is ergodic.
With a teleport probability $\alpha = 1 - d > 0$, every entry of the transition matrix $G$ is at least $(1 - d)/N > 0$: from any page the surfer reaches any page in one step by teleporting. A product of matrices with all entries positive has all entries positive, since each entry of the product is a sum of products of positive numbers. So every entry of $G^t$ is positive for every $t \ge 1$, and the definition of ergodic holds with $T_0 = 0$. Nothing about the graph was used. This is the reason for teleporting: it makes the chain ergodic whatever the links are.
Problem 4 (Exercise 21.10). Show that the PageRank of every page is at least $\alpha/N$. What does this imply about the differences between PageRank values as $\alpha$ approaches 1?
Write the stationary equation for one page $p$, with $\alpha = 1 - d$:
$$\pi_p = \sum_q \pi_q G_{qp} = d \sum_q \pi_q S_{qp} + \frac{1 - d}{N} \sum_q \pi_q = d \sum_q \pi_q S_{qp} + \frac{1-d}{N}.$$
The first term is a sum of nonnegative numbers, so $\pi_p \ge (1 - d)/N = \alpha/N$. On the five-page web with $d = 0.85$ the bound is $0.03$ and the smallest PageRank is $D$'s $0.0524$.
The same equation bounds each PageRank from above: $\sum_q \pi_q S_{qp} \le \sum_q \pi_q = 1$, so $\pi_p \le d + (1-d)/N$. Every PageRank therefore lies between $\alpha/N$ and $\alpha/N + (1 - \alpha)$, an interval of width $1 - \alpha$. As $\alpha$ approaches 1 the interval shrinks to the single value $1/N$: the PageRanks all approach $1/N$ and the differences between pages vanish. A surfer who almost always teleports is almost uniformly distributed, and the links cease to matter. On the five-page web with $\alpha = 0.99$ the PageRanks lie between $0.198$ and $0.202$.
Problem 5 (Exercises 21.16 to 21.18). Every page has a sports PageRank $\pi_s$ and a politics PageRank $\pi_p$, computed with the same teleport probability $\alpha$. A user's interests are a fraction $q$ sports and $1 - q$ politics. Show that the steady state of the walk that, on a teleport step, jumps to a sports page with probability $q$ and to a politics page with probability $1 - q$ is $q\,\pi_s + (1 - q)\,\pi_p$.
Let $s$ and $p$ be the teleport distributions over sports pages and over politics pages. The user's walk teleports according to $v = q\,s + (1-q)\,p$, which is again a probability distribution. The identity is exact under a condition the exercise leaves unstated: either the graph has no dangling page, or dangling pages jump by a fixed rule that does not depend on the topic. In the course text's own walk a dangling page teleports like any other, to the topic's pages, and on a graph with dangling pages the identity then fails. The five-page web is such a graph: its 60/40 walk is a mixture of the two single-page vectors with weights $0.571$ and $0.429$, not 0.6 and 0.4, as shown in Why vectors can be combined. We prove the identity under the condition. By that section, with the dangling rows fixed (or absent), the steady state for any teleport distribution $v$ is $\pi_v = (1-d)\,v^{\mathsf{T}}(I - dS)^{-1}$. Substituting $v$,
$$\pi_v = (1-d)\,\big(q\,s + (1-q)\,p\big)^{\mathsf{T}}(I - dS)^{-1} = q\,(1-d)\,s^{\mathsf{T}}(I - dS)^{-1} + (1-q)\,(1-d)\,p^{\mathsf{T}}(I - dS)^{-1} = q\,\pi_s + (1-q)\,\pi_p.$$
The steady state exists and is unique because $I - dS$ is invertible, which needed only $d < 1$. For each page $i$ this reads $\pi_v(i) = q\,\pi_s(i) + (1-q)\,\pi_p(i)$, the statement of Exercise 21.18. The five-page check in that section, with $A$ in the role of sports, $D$ in the role of politics and $q = 0.6$, is an instance.
What we have learned
PageRank is the stationary distribution of a random surfer who follows links with probability $d$ and otherwise jumps. With dangling pages repaired, teleportation makes every entry of $G$ positive, so there is exactly one answer. On the five-page web it puts $A$ first, at $0.3171$, with a single in-link. Power iteration's error shrinks by at least the factor $d$ per step on any web, and by about $0.5534$ per step on the example. Personalized PageRank changes where the surfer jumps, and with the dangling rows fixed it is linear in the teleport distribution.
PageRank is computed once for the whole collection. HITS: Hubs and Authorities treats the other classical method of link analysis, which computes two scores for each page on a small graph built for one query. After it, Monitoring websites shows how much of this topic carries over to the small job most programs that fetch pages do: watching a handful of pages and reporting when something changes.
References
- Brin, S., and Page, L. (1998). The anatomy of a large-scale hypertextual Web search engine. Computer Networks and ISDN Systems, 30(1–7), 107–117. record · 4 pages
- Google Search Central (2019). Evolving "nofollow": new ways to identify the nature of links. Google Search Central Blog, 10 September 2019. developers.google.com/search/blog/2019/09/evolving-nofollow-new-ways-to-identify (accessed November 2026). record
- Gutiérrez, B. J., Shu, Y., Gu, Y., Yasunaga, M., and Su, Y. (2024). HippoRAG: Neurobiologically inspired long-term memory for large language models. In Advances in Neural Information Processing Systems 37 (NeurIPS 2024). record
- Haveliwala, T. H. (2002). Topic-sensitive PageRank. In Proceedings of WWW 2002, 517–526. record
- Haveliwala, T. H., and Kamvar, S. D. (2003). The second eigenvalue of the Google matrix. Technical report, Stanford University. record
- Jeh, G., and Widom, J. (2003). Scaling personalized web search. In Proceedings of WWW 2003, 271–279. record
- Kleinberg, J. M. (1999). Authoritative sources in a hyperlinked environment. Journal of the ACM, 46(5), 604–632. record · 3 pages
- Langville, A. N., and Meyer, C. D. (2006). Google's PageRank and Beyond: The Science of Search Engine Rankings. Princeton University Press. record
- Lempel, R., and Moran, S. (2000). The stochastic approach for link-structure analysis (SALSA) and the TKC effect. Computer Networks, 33(1–6), 387–401. record · 2 pages
- Manning, C. D., Raghavan, P., and Schütze, H. (2008). Introduction to Information Retrieval, chapter 21. Cambridge University Press. record · 102 pages
- Norris, J. R. (1997). Markov Chains. Cambridge University Press. record · 3 pages
- Page, L., Brin, S., Motwani, R., and Winograd, T. (1999). The PageRank citation ranking: Bringing order to the Web. Technical report, Stanford InfoLab. record
Reviewed: verified, 16 Nov 2026 · checked against sources, 23 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 23 Nov 2026 · edited since · 16 revisions