MST Visualizer
Graph Algorithms Greedy + Union-Find

Kruskal's MST Algorithm

interactive_graph.svg — sorted edges processed left → right

Currently checking
In MST
Unprocessed
MST edge
Rejected (cycle)
Sorted edge queue (ascending weight)
Union-Find — disjoint sets
Step 0 of 9

pseudocode.txt — kruskal

complexity.md

// why union-find?

Kruskal's must check if two nodes are already connected before adding an edge. Union-Find answers "same component?" in near O(1) using path compression + union by rank — making it ideal for this repeated query.

// kruskal's vs prim's

Kruskal's sorts all edges globally and works component-to-component — best for sparse graphs. Prim's grows from one vertex — better for dense graphs. Kruskal's is also easier to parallelize since edge sorting is independent.

// cycle detection insight

Adding an edge between nodes in the same component creates a cycle. Union-Find's find() operation returns the root representative of each component — identical roots means same component → skip the edge.