Prim's Minimum Spanning Tree
Grow one connected tree through the lightest crossing edge
Start small and keep the tree connected
Prim's algorithm starts from one vertex. At every step it considers edges with exactly one endpoint inside the current tree, chooses the lightest such edge, and brings the outside endpoint into the tree. After V - 1 choices, every vertex is connected.
Read the expanding cut
Green vertices and edges are already inside the tree. The amber edge is the lightest edge crossing from that set to an outside vertex. Advancing one step adds both the edge and the new vertex, so the selected structure remains connected at all times.
Start at A; the tree initially contains one vertex.
Correctness and implementation choices
The cut property makes each lightest crossing edge safe. A binary heap implementation runs in O(E log V) on adjacency lists, while a simple dense-graph implementation can run in O(V^2). The visualization scans a compact fixed edge set so every choice stays visible.
See the same objective approached from a forest in Kruskal's algorithm.