Part II · PageRank — the web as a Markov chain

draft

The most consequential Markov chain ever built has one state per web page. Google's founding algorithm did not invent a new kind of mathematics — it noticed that *ranking the web is the same problem as finding the stationary distribution of a random walk* (ch. 01, §4). This chapter is that observation, made precise.


1. The idea: importance is where a random surfer lingers

In 1996, Stanford PhD students Larry Page and Sergey Brin started a project nicknamed "BackRub" — an engine that judged a page not by the words on it but by the back links pointing to it. Renamed Google in 1997 (incorporated September 1998), it rested on one model:

The random surfer. Imagine someone browsing forever. At each page, with probability \(d\) they click a uniformly random outbound link; with probability \(1-d\) they get bored and teleport to a uniformly random page anywhere on the web. The PageRank of a page is the long-run fraction of time this surfer spends on it. Important pages are simply the ones a random walk keeps returning to — because many pages link to them, and because the pages linking to them are themselves important.

That last clause makes the definition recursive (a page's rank depends on the ranks of its linkers), and that recursion is exactly what a stationary distribution resolves.


2. The math: rank = stationary distribution

Model the web as a directed graph: pages are states, hyperlinks are edges. Let \(L(i)\) be the number of outbound links from page \(i\). The surfer's move depends only on the page it is currently on — the Markov property. Its transition matrix is

\[M = d\,S + (1-d)\,\tfrac{1}{N}\,\mathbf{1},\]

where \(S\) is the link matrix (each page's mass split evenly over its out-links, with dead-end "dangling" pages patched to teleport uniformly) and \(N\) is the number of pages. PageRank is the stationary distribution \(\pi\) of \(M\) — the vector with \(\pi = M\pi\), equivalently the principal eigenvector (eigenvalue 1) of \(M\). Written per page:

\[PR(p) = \frac{1-d}{N} + d \sum_{i \in \text{In}(p)} \frac{PR(i)}{L(i)}, \qquad d \approx 0.85.\]

Each page hands its rank to its targets, divided evenly; the \((1-d)/N\) term is the teleport. (The original 1998 paper wrote the teleport as \((1-d)\); the normalized \((1-d)/N\) form above is the one that makes the ranks a genuine probability distribution summing to 1.)

Why the damping factor is not optional. The raw link graph is a broken Markov chain: it has disconnected islands, rank sinks, and dangling nodes that leak probability — so it need not have a unique, well-defined stationary distribution. The teleport term \((1-d)\) makes every entry of \(M\) strictly positive, which makes the chain irreducible and aperiodic. By the Perron–Frobenius theorem such a chain has a unique stationary distribution with strictly positive entries, and the walk converges to it from any start. Damping is the trick that turns a malformed graph into a chain the fundamental theorem applies to.

How it is computed — power iteration. Start from a uniform vector and repeatedly apply \(M\): \(\pi_{k+1} = M\pi_k\). This is running the random walk in aggregate; it converges geometrically (the rate set by the second eigenvalue, bounded by \(d=0.85\)), so a handful of dozens of iterations suffices even at web scale. The early system ran this over roughly 24 million pages and hundreds of millions of links.

Brin, S. & Page, L. (1998). *The Anatomy of a Large-Scale Hypertextual Web Search Engine.* WWW7 / Computer Networks 30:107–117. Page, L., Brin, S., Motwani, R. & Winograd, T. (1999). *The PageRank Citation Ranking: Bringing Order to the Web.* Stanford InfoLab TR SIDL-WP-1999-0120.


3. Why it beat the 1998 web

The competition ranked pages by on-page keywords (AltaVista, Excite, Lycos, Infoseek) or by human-curated directories (the Yahoo! Directory). Keyword ranking treated every page as equally authoritative and was trivially spammed by keyword stuffing; directories could not scale to the web's growth. PageRank contributed a query-independent importance score derived from the link graph itself — the web's own hypertext structure read as a giant citation network — which is far harder to fake: you cannot make yourself important merely by claiming to be, only by getting important pages to link to you. Combined with anchor-text indexing, that was the leap.


4. The pattern generalizes

PageRank is one instance of a reusable move: encode "importance" or "relevance" as the stationary distribution of a walk you design, then read the answer off the fixed point. The same construction drives personalized PageRank, recommendation walks over user–item graphs, citation and trust ranking, and graph-based retrieval. Whenever a system ranks nodes by "how much a random walk favors them," it is computing a stationary distribution — the identical mathematics that samples physics in Monte Carlo & MCMC and predicts text in the AI Compendium.


Why it matters to the Stack

The Stack runs its own search and retrieval surfaces — Koder Hub package search, kode-rag retrieval, cross-repo ranking. Any linkcitationgraph signal these fold into a ranking is, formally, a PageRank-style stationary distribution over a walk on the Stack's own graphs. This chapter is the encyclopedic ground; a component's ranking decision (which graph, which damping, which signals) is an engineering choice that cites it, per the compendium's reference-vs-decision rule.


Sources

  • Brin, S. & Page, L. (1998). The Anatomy of a Large-Scale Hypertextual Web Search Engine. WWW7; Computer Networks and ISDN Systems 30:107–117.
  • Page, L., Brin, S., Motwani, R. & Winograd, T. (1999). The PageRank Citation Ranking: Bringing Order to the Web. Stanford InfoLab Technical Report SIDL-WP-1999-0120.
  • Perron–Frobenius theorem and the random-surfer/teleportation formulation (standard references; cf. Langville & Meyer, Google's PageRank and Beyond, Princeton, 2006).