Prim
Grow one tree from a start vertex, always adding the cheapest edge that leaves it.
Decision · step 2 of 7Minimum Spanning Tree: Prim, growing from 0
Edges leaving the tree: 0-2 (3), 0-1 (4). The cheapest is 0-2 at 3, so 2 joins the tree. Total 3.
What you will see
The tree grows; frontier edges are candidates; the minimum one is chosen each step.
Cost
| Best | O(E log V) |
|---|---|
| Average | O(E log V) |
| Worst | O(E log V) |
| 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.