Examine the technique of building minimum spanning trees by expanding a connected subgraph with the smallest edge at each step.
Prim's algorithm constructs a minimum spanning tree by growing a single tree, one vertex at a time, always choosing the lightest edge that connects the tree to an external vertex. It serves the same problems as Kruskal's, with a different approach [1].
Start from any vertex. At each step, among the edges that connect a vertex inside the tree to one outside, choose the one with minimum weight and add the new vertex. After $n - 1$ steps all vertices are connected. As with Kruskal's, correctness follows from the cut property [1][2].
On the graph in the row about Dijkstra (assumed values), start from $A$.
1. Edges outgoing from $\{A\}$: $AB = 7$, $AC = 9$, $AF = 14$. Choose $AB = 7$.
2. From $\{A, B\}$: $AC = 9$ is the minimum. Add $C$.
3. From $\{A, B, C\}$: $CF = 2$. Add $F$.
4. From $\{A, B, C, F\}$: $EF = 9$ (versus $CD = 11$). Add $E$.
5. From $\{A, B, C, F, E\}$: $DE = 6$. Add $D$.
The total cost is $7 + 9 + 2 + 9 + 6 = 33$, the same as Kruskal's (calculation).
Kruskal sorts all edges and reconstructs a forest; Prim grows a single tree. With a priority queue, Prim's complexity is $O(m \log n)$; with an adjacency matrix and linear search it is $O(n^2)$, preferable in dense graphs. Both find the minimum cost, and if weights are distinct the tree is the same.
Distribution and communication networks, printed circuit boards, cluster analysis (general observation). See also the rows on Kruskal and on trees.
Works only on undirected and connected graphs. Like Kruskal's tree, it does not provide shortest paths between pairs of vertices. It works with negative weights as well, but it is advisable to verify the assumptions used by your implementation.
[1] Wikipedia (it): Algoritmo di Prim
[2] Wikipedia (en): Prim's algorithm
Generating summary…