Concatenate every out-neighbourhood into one string A, mark where each neighbourhood begins in a
bitvector S, and store A in an entropy-compressed wavelet tree. That is the whole
representation — and every navigational operation becomes a constant number of rank /
select calls. A costs m·H0(A) bits, and H0(A)
is exactly the graph's zeroth-order in-degree entropy. Step 2 attacks that term by extracting a tree.
Nothing is renamed here: vertices keep the input's own names 0 … n−1, and only
array positions are 1-based, as in the paper. The relabelling arrives in Step 2, where the extracted tree
induces it.
Small screen: this is the compact demo — the graph, the two arrays, the step scrubber and the
answer. The wavelet-tree descent, the pseudocode with live line highlighting and the vertex table are on
the desktop version.
Refinement
Edges
Detail
Delay
750ms
Graph G
Adjacency list
vertex
argument of the call
answer
being examined
drag a vertex to re-lay-out · hover for its block
Wavelet tree over A
What just happened
Pick an operation, click its arguments in the graph, then press Run.
Pseudocode
Verticeslabel · out/in degree
Spacebits
All pseudocode · every routine on this page, by structure
Edit / paste a graph · algs4 format with optional coordinates
Format (Sedgewick & Wayne
Optional fixed layout: after the edges, add exactly
A third number on an edge line (a weight) is ignored. In undirected mode each line is one undirected edge, stored once, oriented v→w exactly as written: an arbitrary orientation is all Step 1 needs, and choosing it well is what Step 2 is about.
Digraph / Graph): vertex count V,
then edge count E, then E lines v w. Vertices are
0 … V−1 — that 0-base is the input's convention and is kept as the
vertex's visible name; array positions are 1-based, following the paper.
Optional fixed layout: after the edges, add exactly
V further lines of
x y, one per vertex in order. Any numeric scale works — it is centred and scaled to fit,
preserving aspect ratio. The box is refilled with the current layout after every load and after every
drag, so you can copy a layout back out.
A third number on an edge line (a weight) is ignored. In undirected mode each line is one undirected edge, stored once, oriented v→w exactly as written: an arbitrary orientation is all Step 1 needs, and choosing it well is what Step 2 is about.