Random Traversal III
A canvas spanning tree floods with color as an animation, where hue represents Manhattan distance from the root. A Web Worker generates the maze using random traversal, and the main thread colors it via a d3.timer loop, writing pixel data with Canvas `putImageData`. The code uses d3.v3 for color and timing, with bitwise direction flags to track tree edges.
AI-generated descriptionA spanning tree of the canvas is generated using random traversal and then flooded with color. Hue encodes Manhattan distance from the root of the tree. (This is not an optimal visual encoding, but it suffices and is pretty.)
Spanning trees can also be used to generate mazes. See a maze generated with random traversal flooded with color, and compare color floods of spanning trees generated with random traversal to randomized depth-first traversal, Wilson’s algorithm and Prim’s algorithm.