Minimum Spanning Tree — Kruskal & Prim (2D)
2D Canvas lab running the real Kruskal and Prim minimum-spanning-tree algorithms step by step on a weighted graph, with a live union-find/adjacency state readout.
This 2D companion runs the unmodified Kruskal and Prim minimum-spanning-tree algorithms on a random weighted graph rendered with Canvas 2D. Kruskal sorts every edge by weight and uses a real Union-Find (disjoint-set) structure to greedily accept the cheapest edge that does not create a cycle; Prim grows a single tree from a seed node, always adding the cheapest edge that reaches a node outside the current tree. Toggle between algorithms and watch two different greedy strategies converge on the same optimal tree, edge by edge.
2D Canvas lab running the real Kruskal and Prim minimum-spanning-tree algorithms step by step on a weighted graph, with a live union-find/adjacency state readout.
2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install