Core idea
Prim grows one connected tree from an arbitrary start vertex.
At each step it chooses the lowest-weight edge leaving the current tree.
It works on connected, weighted, undirected graphs.
How it works
- Start from any vertex.
- Find all edges that connect the tree to an unvisited vertex.
- Choose the smallest such edge.
- Add the edge and vertex to the tree until all vertices are included.