Discrete Mathematics and Combinatorics
Why the PageRank Idea Is a Problem About Random Walks
Follow a random web surfer through a three-page example to see how link structure alone can produce a ranking of importance.
Key takeaways
- PageRank treats the web as a directed graph and scores each page by the long-run share of time a random surfer spends there.
- A page is important when important pages link to it, a circular definition that a stationary distribution resolves.
- A damping step, in which the surfer sometimes jumps to a random page, guarantees a single well-defined answer.
- The scores can be computed by repeatedly updating a guess until it stops changing.
- The same reasoning ranks nodes in many kinds of networks, from citations to sports results.
PageRank scores a web page by asking how often an aimless reader, clicking links at random, would find themselves on it. Pages that the walker visits often get high scores. So a question about importance turns into a question about the long-run behavior of a random walk on a graph.
The idea was described by Sergey Brin and Larry Page in the late 1990s while they were graduate students at Stanford, and it became a well-known part of the early Google search engine. Modern search ranking combines a great many signals, so treat PageRank here as a piece of mathematics and not as a description of how any search service works today.
A circular definition
Counting incoming links is the obvious way to rank pages, and it is easy to game: create a thousand empty pages that all point to yours. A better rule says that a link from an important page should count for more, and that a page which links to many others should split its endorsement among them.
That rule reads: a page's score is the sum, over pages linking to it, of each linker's score divided by its number of outgoing links. The definition is circular, since you need the scores to compute the scores. Circular definitions like this are really systems of equations.
The random surfer
Picture a surfer who starts anywhere and at each step picks one of the links on the current page, each equally likely. The next page depends only on the current one, not on the history. That is a Markov chain.
Let r(i) be the long-run probability of being on page i. If the walk has settled down, the probability flowing into each page must equal the probability already there:
r(i) = sum over pages j that link to i of r(j) / (number of links on j) This is exactly the circular scoring rule. A set of probabilities that stays unchanged after a step is called a stationary distribution.
A three-page example
Suppose page A links to B and C, page B links to C, and page C links to A. The equations are:
r(A) = r(C) (only C links to A, and C has one link)
r(B) = r(A) / 2 (A splits its score two ways)
r(C) = r(A) / 2 + r(B) (from A and from B)
r(A) + r(B) + r(C) = 1 (probabilities) From the first two lines, r(C) = r(A) and r(B) = r(A)/2. The total is then 2.5 r(A) = 1, so r(A) = 0.4, r(B) = 0.2 and r(C) = 0.4.
Page C has two incoming links and page A only one, yet they tie. A's single link comes from a strong page that gives it everything. This is the behavior simple link counting cannot produce.
Computing by repetition
For billions of pages you do not solve the equations by hand. You start with equal scores and apply the update rule again and again.
| Step | A | B | C |
|---|---|---|---|
| 0 | 0.333 | 0.333 | 0.333 |
| 1 | 0.333 | 0.167 | 0.500 |
| 2 | 0.500 | 0.167 | 0.333 |
| 3 | 0.333 | 0.250 | 0.417 |
The numbers wobble and then settle toward 0.4, 0.2 and 0.4. In matrix terms, the stationary vector is an eigenvector of the transition matrix with eigenvalue 1, and repeated multiplication is called the power method. The matrix is a rescaled version of the adjacency matrix of the link graph.
Where the plain walk breaks
Real link graphs cause two problems.
Dead ends. A page with no outgoing links leaves the surfer with nowhere to go, and probability leaks away. A common repair is to treat such a page as linking to every page.
Traps. A group of pages that link only among themselves will eventually capture the surfer and soak up all the score. The surfer can also be stuck in a rigid cycle, so the scores keep oscillating and never settle.
Both are failures of the walk to be able to get from anywhere to anywhere without locking into a pattern.
The damping factor
The fix is to let the surfer get bored. With probability d, called the damping factor, follow a random link. With probability 1 − d, jump to a page chosen at random from the whole collection of N pages. The rule becomes
r(i) = (1 − d)/N + d × [ sum over linkers j of r(j) / links(j) ] The original paper mentioned d = 0.85. With that value in our three-page web, solving the equations gives about A = 0.388, B = 0.215 and C = 0.397. The ranking is similar, but the random jumps have pulled the scores slightly toward equality.
Solving the damped example
It is worth checking those numbers yourself. With d = 0.85 and N = 3, the random jump contributes 0.15/3 = 0.05 to every page.
A = 0.05 + 0.85·C (C gives A its whole score)
B = 0.05 + 0.425·A (A splits between B and C)
C = 0.05 + 0.425·A + 0.85·B
Substitute B into C:
C = 0.0925 + 0.78625·A
Substitute C into A:
A = 0.05 + 0.85·(0.0925 + 0.78625·A)
A ≈ 0.388, then B ≈ 0.215 and C ≈ 0.397 The three add to 1, a handy check on the arithmetic. Compared with the undamped answer, B gained the most. Weak pages benefit from the jumps because every page receives the same baseline, whatever its links.
Notice also that C now edges ahead of A. Without damping the two tied exactly, so even a small change in the model can break a tie. Small differences in score should not be read as meaningful differences in importance.
Why there is exactly one answer
With damping, every page can be reached from every other page in a single step, with positive probability. A theorem about matrices with positive entries, due to Oskar Perron and extended by Georg Frobenius in the early 1900s, then guarantees one and only one stationary distribution, with every score positive.
Damping also controls the speed. Each iteration shrinks the total error by at least a factor of d. With d = 0.85, fifty rounds reduce it by a factor of about 3,000, since 0.85⁵⁰ is roughly 0.0003. A larger d follows the link structure more faithfully but converges more slowly and makes scores more sensitive to small changes in the links.
A useful comparison
On an undirected network with no damping, where the walker can reach every vertex and does not alternate in a fixed rhythm, the stationary probability of a vertex is proportional to its number of neighbors. Ranking then reduces to counting. Direction is what makes web ranking interesting: a link from you to me says nothing about a link from me to you.
Related questions about whether a walker returns to the start, and how often, appear in random walks and returning home.
Gaming the score
Because the score depends on link structure, people have tried to manufacture links. Clusters of pages that link to one another to inflate a target are called link farms. Search services respond with other signals and with methods that detect unnatural patterns. One mathematical idea is to restrict the random jumps to a trusted set of pages, which makes it harder for an isolated cluster to collect score.
The same trick personalizes results: if the jumps land only on pages about a topic you care about, the scores describe importance as seen from that topic.
Other uses of the idea
Ranking by "being endorsed by the well-endorsed" appeared in other fields before the web, including studies of social status and of journal citations. Versions are applied to:
- ranking teams, where a loss passes score to the winner,
- finding influential papers in citation networks,
- identifying central proteins or species in biological networks,
- suggesting accounts to follow in social networks.
Each use needs care. A score measures the structure of the links you fed in, not quality or truth.
Common mistakes
- Counting a page's own outgoing links as support. Adding links on your page does not directly add score to you. It changes how your score is divided, and it can change which pages link back through longer routes.
- Reading scores as percentages of quality. A score of 0.4 in a three-page web and 0.4 in a web of a million pages mean very different things, because all scores share a total of 1.
- Forgetting dead ends in a hand calculation. If the scores stop adding to 1 as you iterate, probability is leaking through a page with no links.
- Updating in place without saying so. In the table above, each row is computed entirely from the previous row. Using new values immediately is a different method that can also converge, but its intermediate numbers will differ.
Common questions
Is PageRank named after web pages?
It is generally described as a play on the name of Larry Page that also fits web pages.
Do the scores have to add to 1?
In the probability version, yes. Some presentations scale them differently, which changes the numbers but not the order.
Do I need to simulate surfers?
No. You could estimate the scores with simulated walks, in the spirit of Monte Carlo methods, but repeating the update rule is usually more accurate for the effort.