← Gallery

Maze

Six ways to grow a spanning tree over the same grid. Same guarantee every time, and six completely different textures.

Output

A set shares every setting — paper, border, the sketch’s own knobs — and differs only in the seed. Regenerate any one of them without touching the others.

PNG: 3508 × 4961 px at 300 dpi. PDF: vector, RGB, 297 × 420 mm page, no bleed. Printed area 297 × 420 mm.

0 mm

Millimetres of unprinted paper on every side. The piece is composed to fit what is left, not shrunk to fit it.

Maze

All six produce a perfect maze. Only the texture differs — and it differs enormously.

26
0.00

Proportion of dead ends opened up into a loop. Above zero it is no longer a tree, and there is more than one way to get anywhere.

Drawing

Drawing the passages draws the spanning tree itself — one line per edge of the graph — which is what makes the difference between the algorithms obvious.

The single route from the top-left cell to the bottom-right one. In a perfect maze there is exactly one.

0.00

Passages only: cut the corners off every turn, by this fraction of a cell.

2.00
40

Colour

Distance is a breadth-first sweep out from the top-left cell, counted in passages rather than in pixels. It draws the shape of the tree.

How it works

Every maze here is a spanning tree of the same grid graph: every cell reachable from every other, and exactly one route between any two. That guarantee holds whichever algorithm built it. What changes is the texture, and it changes enormously — which is the reason to have six of them behind one control rather than one of them done well.

Depth-first backtracking always carries on from where it just was, so it makes long winding corridors. Randomised Prim’s grows from anywhere on the frontier at once, so it makes a bush of short stubs. Kruskal’s shuffles every wall and knocks each one out if it joins two separate regions, and looks as even-handed as that sounds. Wilson’s is the interesting one: it takes a random walk and erases its own loops as it goes, and the theorem is that this samples uniformly from every possible spanning tree — the only algorithm here with no bias at all, which is why it is worth the extra code. The binary tree and sidewinder are the cheap ones and they wear their bias openly, as a corridor along two edges and a diagonal grain through everything else.

Braiding then breaks the guarantee on purpose by knocking a wall out of dead ends: the result has loops, so it is no longer a tree, but it also has no stubs, which reads far better as a drawing. Drawing the passages rather than the walls draws the tree itself, one line per edge, which is where the differences between the six become obvious. And a breadth-first sweep out from the top-left cell does double duty — it colours every cell by how far it is from the start, and read backwards from the far corner it is the single route through.

R regenerate · S PNG · P PDF