What is a Kruskal Algorithm Visualizer?
A Kruskal algorithm visualizer shows how a minimum spanning tree is built by sorting weighted edges and accepting only the edges that connect different components. It is useful for learning MST algorithms, cycle detection, union find, and graph interview problems.
This tool lets you paste undirected weighted edges, then step through each accepted or rejected edge while watching the disjoint-set parent table.
For the full graph and data structure set, browse the Data Structure Visualizers hub.
How to use this Kruskal visualizer
- Paste one undirected weighted edge per line, such as
A B 4. - Click Run Kruskal to jump to the completed MST or forest.
- Step through the sorted edge list to see which edge is considered next.
- Green edges are accepted into the MST.
- Red edges are rejected because they would create a cycle.
Kruskal and union find
Kruskal uses union find to track which nodes already belong to the same connected component. When an edge connects two different roots, it is safe to accept. When both endpoints already share a root, accepting the edge would form a cycle.
Compare this page with the Prim Algorithm Visualizer to see the frontier-growing MST approach. Use the Union Find Visualizer to inspect the disjoint-set operations directly. For an all-pairs shortest path matrix instead of an MST, use the Floyd Warshall Visualizer.