Overview
Prim's Algorithm grows one connected tree, using a priority queue to choose the lightest frontier edge.
Builds a minimum spanning tree by repeatedly attaching the cheapest edge from the tree to a new node.
Compact metadata for implementation and discovery.
Prim's Algorithm grows one connected tree, using a priority queue to choose the lightest frontier edge.
Quick facts
Runtime and memory behavior at a glance.
Best
O(E log V)
Average
O(E log V)
Worst
O(E log V)
Space
O(V + E)
priority(v) = minimum weight edge from tree to vRanks outside nodes by their cheapest connection to the current tree.
Show a connected tree expanding through its cheapest frontier edge.
The priority-queue structure resembles Dijkstra's Algorithm, but the priority is edge cost rather than path distance.
What each reference supports for this entry.
Textbook support for Prim's Algorithm's standard algorithm design, invariants, and complexity analysis.
Open sourceAlgorithm catalog support for Prim's Algorithm's problem context, known alternatives, and practical selection tradeoffs.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Prim's Algorithm solves the minimum spanning tree problem by growing a frontier.
Prim's Algorithm commonly uses a priority queue for candidate edges.