Kruskal
Sort the edges by weight and take each one that joins two different components, which union-find answers.
Decision · step 2 of 9Minimum Spanning Tree: Kruskal, cheapest edges first
Edge 1-2, weight 1. 1 is in component 1 and 2 in component 2, different, so take it: they merge and the total is 1.
What you will see
SORT EDGES -> take the lightest -> CHECK COMPONENTS -> ACCEPT (merge) or REJECT (would form a cycle).
Cost
| Best | O(E log E) |
|---|---|
| Average | O(E log E) |
| Worst | O(E log E) |
| Space | O(V) |
How you work with it here
play it through, step one change at a time, scrub to any step, run it on your own input, predict what happens next, try operations in any order.
Screen readers: Edges announce endpoints, weight and state (candidate, accepted, rejected); each step announces the decision and the reason.
Reduced motion: Accepted edges thicken with a crossfade; no travelling highlights.