Prim's algorithm (source code)

= Prim's algorithm
{wiki=Prim's_algorithm}

Prim's algorithm is a greedy algorithm used to find the Minimum Spanning Tree (MST) of a weighted, undirected graph. A Minimum Spanning Tree is a subset of edges that connects all vertices in the graph without any cycles and with the minimum possible total edge weight. \#\#\# How Prim's Algorithm Works: 1. **Initialization**: Start with an arbitrary vertex and mark it as part of the MST.