Skip to main content
100%

Prims Algorithm

✓ Published0🌍 Public
Aadamhurst
Last edited Aug 31, 2015
Created on Aug 31, 2015

This animated canvas visualization demonstrates Prim’s algorithm for generating a spanning tree on a 900×600 grid. A web worker computes the maze structure using a minimum-heap priority queue, randomly selecting edges to connect cells. The animation then floods the resulting tree from its root, using D3’s Cubehelix color scale to map hue to Manhattan distance from the root. The canvas rendering updates in timed intervals, creating a smooth color wave that reveals the tree’s structure.

AI-generated description

Prims Algorithm Visualisation

Slight modification of Mike Bostok's visualisation, using a single Cubehelix color scale.

A spanning tree of the canvas is generated using Prim’s algorithm and then flooded with color. Hue encodes Manhattan distance from the root of the tree.

Similar vizzes