Prim's Algorithm
Prim's Algorithm
Introduction
A weighted undirected graph with vertices and edges is given. It is required to find a spanning tree of this graph that connects all vertices and has the smallest total weight (that is, the sum of the edge weights is minimal).
Algorithm
Choose an arbitrary vertex . Create a set consisting of a single vertex , that is . Next, perform iterations: