Prim’s Algorithm

Back to Minimum Spanning Tree

A greedy algorithm that grows the MST one vertex at a time by always adding the cheapest edge connecting the tree to a non-tree vertex. O((V + E) log V) with a binary heap. Well-suited for dense graphs.

algorithms graph-algorithms prims mst