Documentation
¶
Overview ¶
Example 05_out_of_core — Tier 2 external memory: build a scale-free web graph, persist its CSR adjacency as an on-disk csrfile, re-open it by mmap, and run semi-external PageRank directly over the mapped region.
What it demonstrates ¶
Tier 2 is GoGraph's external-memory storage tier: the CSR adjacency lives on disk in the csrfile binary format and is read back by mmap'ing the file and reinterpreting its aligned sections as typed slices in place — no parse, no copy into the heap. This contrasts with Tier 1, the fully in-memory CSR snapshot built by csr.BuildFromAdjList. The semi-external extern.PageRankCtx keeps only the rank vector in RAM (size = vertex count) while streaming the adjacency sequentially from the mapped file on every iteration, so the resident working set is bounded by the vertex count rather than the much larger edge count. That is the headline out-of-core advantage this example measures: the on-disk adjacency dwarfs the resident heap.
Model ¶
The dataset is a directed, scale-free hyperlink graph generated by Price's model (de Solla Price, 1965/1976) — the directed preferential-attachment process that is the canonical domain for PageRank. Nodes arrive in id order 0..N-1; each new node v emits m out-links, choosing each target with probability proportional to the target's current in-degree plus a small attractiveness constant a (in-degree exponent gamma_in = 2 + a/m). This produces a heavy-tailed in-degree distribution: a few early-arriving nodes accrue most of the incoming links and become high-PageRank authorities, while the bulk hold near-uniform low rank.
Because the authorities separate from the bulk by a wide margin, the top-k highest-PageRank node ids (tie-broken by ascending id) are a stable, meaningful fact — unlike a uniform ring, whose PageRank is flat and has no ranking to report. Fixing -seed fixes the data shape, and therefore the top-k, exactly: the generator draws from a single seeded math/rand source, emits each node's targets in draw order, and the semi-external PageRank sums in a fixed CSR-row order, so the deterministic facts are byte-identical across machines.
Scale ¶
Run with no flags, the example builds a small deterministic default (5000 nodes, ~20k edges) that completes in milliseconds — the size the regression test pins. The same binary scales up to where the out-of-core footprint advantage is observable:
go run ./examples/05_out_of_core -nodes 1000000 -out-degree 8
At one million nodes and eight out-links each the on-disk csrfile is on the order of ~69 MiB while the resident rank vector is only ~8 MiB — the adjacency lives on disk, not in RAM. Every dimension is a flag, and only the telemetry (lines prefixed "# ") varies between runs and machines; the fact lines are reproducible for a fixed -seed.