AlgoScope

Prim

AlgorithmintermediateMinimum Spanning Tree

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
431242650✓12345

Edges leaving the tree: 0-2 (3), 0-1 (4). The cheapest is 0-2 at 3, so 2 joins the tree. Total 3.

Open in the player →or start at step 2

What you will see

The tree grows; frontier edges are candidates; the minimum one is chosen each step.

How minimum spanning tree works →

Cost

BestO(E log V)
AverageO(E log V)
WorstO(E log V)
SpaceO(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.

Taught by the same lesson

Minimum Spanning Tree covers these too, in the same run.