Kruskal MST
Sorts all edges by ascending weight, then adopts only the edges that don't form a cycle to build a minimum spanning tree (MST). Cycle checks run in O(α) with union-find.
01Kruskal MST
Explore How It WorksStarting Kruskal. Sort all edges by ascending weight and place each node in its own set.
Start with the lightest edge, AB(1). A and B are in different sets, so joining them makes no cycle: add it to the MST and merge the sets.
BC(2) · different sets, so add it. {A,B} and C merge into one.
AC(3) · A and C are already in the same set. Joining them here would form a cycle, so reject it.
CD(4) · different sets, so add it. D joins {A,B,C}.
BD(5) · B and D are already one set too. That would form a cycle as well, so reject it.
DE(6) · the last set E joins. With 4 edges (5 nodes − 1), the MST is complete.
Done · MST = AB + BC + CD + DE, total weight 13. CE(7) is skipped since everything is already one set.
02 Understand It Simply
For EveryoneWalks the edges from lightest to heaviest and keeps only those that do not close a cycle. The starting vertex makes no difference to the result.
Sorts edges by weight and adopts only those that create no cycle.
Union-find checks for cycles quickly.
- –Least-cost network design
- –building road and telecom networks
03 Python Implementation
A clean, readable reference implementation of the core logic of Kruskal MST.
04 Frequently Asked Questions
FAQWhat is Kruskal MST?+
Sorts all edges by ascending weight, then adopts only the edges that don't form a cycle to build a minimum spanning tree (MST). Cycle checks run in O(α) with union-find.
What is the time complexity of Kruskal MST?+
The time complexity of Kruskal MST is O(E log E). Follow the step-by-step visualization to see exactly why.
Where is Kruskal MST used?+
Least-cost network design, building road and telecom networks.
What's a simple analogy for Kruskal MST?+
Walks the edges from lightest to heaviest and keeps only those that do not close a cycle. The starting vertex makes no difference to the result.
