block by mbostock 83d1073cb0a45ac158fb

Prim’s Algorithm II

Full Screen

This maze is generated using Prim’s algorithm and then flooded with color. Hue encodes Manhattan distance from the starting cell. (This is not an optimal visual encoding, but it suffices and is pretty.)

Color is useful to visually compare the structure of mazes; without color, the black and white alternating cells are too noisy to offer any pre-attentive comparisons. Compare a maze generated by Prim’s algorithm to random traversal, randomized depth-first traversal and Wilson’s algorithm.

See this color flood applied directly to the pixel grid.