Mental Model
Prim's algorithm grows a tree by adding the cheapest edge that connects a new node to the tree until all nodes are included.
Analogy: Imagine building a road network connecting cities. You start from one city and always pick the shortest road to a city not yet connected, gradually linking all cities with minimum total road length.
Graph nodes: 1, 2, 3, 4 Edges with weights: 1 --2-- 2 1 --3-- 3 2 --1-- 3 2 --4-- 4 3 --5-- 4 Initial tree: [1] (start node) Other nodes: 2, 3, 4
