Documentation
¶
Overview ¶
Example 08_pagerank — runs PageRank over a seeded, scale-free directed web and reports the most authoritative pages, most to least important.
It builds a directed "web" whose in-degree distribution is heavy-tailed (a few authority pages everyone links to, a long tail of pages nobody links to), runs centrality.PageRank over an immutable CSR snapshot of it, reads the per-node ranks back through the adjacency-list [Mapper], and prints a deterministic top-k of pages ordered by rank. Because the in-degree tail is heavy, PageRank is genuinely non-uniform: a stable, clearly separated set of authorities emerges rather than the all-equal scores a symmetric cycle would give.
Model ¶
(:page) -> (:page) // a directed hyperlink; src endorses dst
Pages are named "page%07d" in creation order. Edges point from the linking page to the linked page, so a page's in-degree is how many other pages link to it and PageRank concentrates stationary mass on high-in-degree pages that are themselves linked from high-mass pages.
Topology — Price's directed scale-free model ¶
The web is generated by Price's model (de Solla Price, Science 149:510, 1965; J. Amer. Soc. Inf. Sci. 27:292, 1976) — the canonical directed citation/web preferential-attachment model and the directed counterpart of Barabási–Albert (classic BA is undirected). Each new page emits links out-degree out-edges to existing pages chosen with probability proportional to their current in-degree plus an additive attractiveness constant attract, which puts the heavy tail on the IN-degree (the link targets) and makes even never-linked pages reachable. The resulting in-degree power-law exponent is gamma_in = 2 + attract/links (Newman, Networks 2nd ed. §14.1), so attract < links yields a tail heavier than BA's gamma=3 and a more concentrated PageRank top-k.
Targets are sampled in O(1) amortised time per edge by the redirection / edge-copying technique (Newman §14.1): an append-only target list records every edge's destination, so a node appears in it exactly in-degree times and a uniform pick from the list is an in-degree- proportional pick — no per-node cumulative-degree scan. The whole graph is generated in O(V·links) = O(E) time in a single seeded math/rand pass, so a fixed -seed fixes the shape exactly. This design was confirmed with the project's graph-theory-expert sub-agent.
Scale ¶
Run with no flags the example builds a small deterministic web — 500 pages, 4 out-links per page, attractiveness 1 (gamma_in ≈ 2.25) — that builds and ranks in milliseconds, well under the short-test budget. The earliest-created core pages accumulate the most incoming mass (preferential attachment rewards age), so the top-k is dominated by low-index pages and is stable across runs and machines for a fixed seed. Every dimension is a flag, so the same binary scales up to where PageRank's convergence cost and footprint become observable:
go run ./examples/08_pagerank -pages 1000000 -links 8 -seed 7
Output ¶
Bare lines carry deterministic facts (the top-k page ids by rank, with a stable tiebreak, and the count of distinct rank values), reproducible for a fixed -seed. Lines prefixed with "# " carry volatile telemetry — convergence iterations, wall-clock timing, transient allocations and live heap — that varies per run and per machine. A regression test pins the facts and ignores the telemetry.