Unprocessed Candidate In MST Rejected

Minimum Spanning Tree — Kruskal & Prim (2D)

This 2D companion animates Kruskal's and Prim's minimum-spanning-tree algorithms step by step on a random weighted graph rendered with Canvas 2D. Kruskal sorts all edges by weight and uses a real Union-Find structure to greedily add 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 an unvisited node. Toggle between algorithms, control playback speed, and watch the same optimal tree emerge from two different greedy strategies.