Prim's algorithm
Builds on GraphConnected graphTreeSpanning treeMinimum spanning treeAlgorithm
Definition
Let be a finite connected graph, let be a weight function, and let . Prim's algorithm with start vertex is the following algorithm.
- Set and .
- While , choose an edge with and of least weight among such edges.
- Add to and to , then return to step 2.
At every stage is a tree. At the end, is the edge set of a minimum spanning tree of .
Remarks
Example: let be the triangle on with , , , and let . The first step picks (weight beats ), and the second picks (weight beats ). The result is a spanning tree of least weight .
Non-example: if is not connected, step 2 eventually finds no edge leaving while . The algorithm then only spans the component of .
Correctness follows from the cut property applied to the partition . With a binary heap the running time is , and with a Fibonacci heap it is , where and .
Reading path
To understand this page from the ground up, read these 7 pages in order. The foundations come first.
Show the path as a graph
- no evidence level
- Algorithm concept
- Connected graph concept
- Graph concept
- Minimum spanning tree concept
- Spanning tree concept
- Tree concept
- Prim's algorithm definition
Further reading
About this page
| Tag | T6V9712YMB |
|---|---|
| URI | m2://T6V9712YMB |
| Kind | definition |
| Writing | W0 stub |
| MSC | 05C85, 05C05, 90C27 |
| Defines | Prim's algorithm |
| Uses | Graph, Connected graph, Tree, Spanning tree, Minimum spanning tree, Algorithm |
| Changed | 3 November 2026 |
Markdown · JSON · Edit on GitHub
What this page needs for W1
- an inventory row: the row of the inventory that the node accounts for (0 of 1)
- a source with a locator (0 of 1)
The writing levels say how complete the text of a page is. They do not measure its truth.
What links here
No page links to this page yet.