Loading...
Greedy vertex-based Minimum Spanning Tree expansion.
Grow the tree one vertex at a time
Choose minimum crossing edge
Track best edges to neighbors
Prim's algorithm starts with a single vertex and greedily expands the tree by adding the nearest vertex (smallest weight edge) connecting the existing tree to an outside vertex. This "nearest neighbor" property ensures we always make a safe choice for the MST.