How the random walk works

Let the current Wikipedia page be a node v. Each step queries the MediaWiki API for the set of internal links L(v) within namespace 0, excluding "List of" pages. The next node is drawn uniformly at random from L(v) \ {parent(v)}. When a page is revisited, it is treated as the same node.

The walk edges are stored as an undirected multigraph G_w where weights count traversals. In parallel, each node stores its category set C(v). When a node is first seen, we compute the Jaccard similarity J(u, v) = |C(u) ∩ C(v)| / |C(u) ∪ C(v)| against previous nodes, keeping the top three non-zero matches. These produce similarity edges in G_s with weight J(u, v). The union G = (V, E_w ∪ E_s) drives layout and distance calculations.

Layout uses a force-directed system from D3: nodes experience a repulsive 1/r² charged force, spring forces on edges, and a collision radius to prevent overlap. The natural edge length for walk edges scales inversely with √(weight), making frequently traversed connections tighter. Similarity edges use a longer base length (≈220px) scaled by category overlap.

The minimum hop distance from the seed node is recomputed after each step via breadth-first search over G, giving d(v). Node colour is sampled from a white→red→black gradient using d(v) / max₍finite₎ d, and the seed node is highlighted bright green at twice the radius of other nodes. Collision radius and label placement use the scaled node radius.

Audio cues are synthesised with the Web Audio API. New nodes trigger a short sine-curve pop; new similarity edges play a dual-oscillator chime. All sounds are envelope-shaped to avoid clipping.
Controls update shared state and trigger a lock-free async loop that continuously steps the walk while state.running is true.