Generated by GPT-5-mini| Prim's algorithm | |
|---|---|
| Name | Prim's algorithm |
| Type | Graph algorithm |
| Problem | Minimum spanning tree |
| Time complexity | O(E + V log V) (with binary heap) |
| Space complexity | O(V + E) |
| Invented by | Robert C. Prim |
| Year | 1957 |
Prim's algorithm
Prim's algorithm finds a minimum spanning tree in a connected, weighted, undirected graph by growing a single tree one edge at a time. It produces a spanning tree that minimizes total weight and is widely used in network design, computational geometry, and electrical engineering projects associated with Bell Labs, Massachusetts Institute of Technology, Stanford University, Carnegie Mellon University, and Princeton University. The method connects to classical results in combinatorial optimization studied alongside work at IBM, AT&T, Harvard University, University of Cambridge, and University of California, Berkeley.
Prim's algorithm operates on a graph G = (V, E) with vertex set V and edge set E and nonnegative edge weights. Starting from an arbitrary seed vertex drawn from V, the algorithm repeatedly adds the minimum-weight edge that connects a vertex in the growing tree to a vertex outside it, respecting the constraints proved in the theory developed by researchers at Bell Labs, Courant Institute, Institute for Advanced Study, École Polytechnique, and University of Illinois Urbana-Champaign. It is intimately related to the greedy paradigm used in classic results taught at Columbia University, Yale University, University of Chicago, University of Oxford, and University of Cambridge.
The basic procedure maintains a set S of vertices included in the partial spanning tree and a set of candidate edges crossing the cut (S, V \ S). At each iteration, the algorithm selects a minimum-weight edge (u, v) with u in S and v not in S, adds v to S and the edge to the tree, and updates the candidate set. Implementations rely on priority queues studied in works associated with Donald Knuth, Robert Tarjan, Edsger Dijkstra, John Hopcroft, and Judea Pearl to extract the minimum efficiently. The algorithm terminates when S = V, producing a tree that can be validated using matroid theory developed at Rutgers University, University of Waterloo, California Institute of Technology, and University of Toronto.
Correctness follows from a cut property proved in textbooks used at Stanford University, MIT, Princeton University, UC Berkeley, and Harvard University: for any cut, the minimum-weight crossing edge belongs to some minimum spanning tree. The greedy choice is justified via exchange arguments familiar from studies at Bell Labs and AT&T. Time complexity depends on the edge data structure: naive adjacency-matrix implementations connect to analyses in Newton Institute and run in O(V^2), while adjacency-list implementations with binary heaps achieve O(E + V log V) as shown in results credited in lectures at Carnegie Mellon University and Cornell University. Using Fibonacci heaps, following work by Robert Tarjan and collaborators at Princeton University and Rutgers University, yields O(E + V log V) with better amortized bounds in theoretical treatments appearing in courses at Yale University and Columbia University.
Canonical implementations use arrays, binary heaps, pairing heaps, or Fibonacci heaps; practical systems at Google, Microsoft Research, Facebook, Amazon Web Services, and NASA often prefer pairing heaps or binary heaps for engineering trade-offs. Variants include dense-graph optimizations, lazy implementations used in software from Apache Software Foundation and Linux Foundation projects, and parallel versions inspired by research at Lawrence Berkeley National Laboratory, Los Alamos National Laboratory, Argonne National Laboratory, and Sandia National Laboratories. Distributed and external-memory adaptations draw on cluster computing work at Google, Microsoft Research, IBM Research, Intel Labs, and Amazon. For planar graphs, specialized algorithms linked to research at ETH Zurich, EPFL, and University of Tokyo can outperform general-purpose implementations.
Practical applications include design and analysis of telecommunication networks modeled in projects at Bell Labs, AT&T, Verizon, and Cisco Systems; power-grid planning in work at General Electric and Siemens; and image segmentation routines in computer vision research at MIT, Carnegie Mellon University, University of California, Berkeley, and University of Oxford. Examples in computational geometry and mesh generation appear in studies at ETH Zurich, INRIA, Max Planck Society, and Los Alamos National Laboratory. Educational examples are commonly presented in curricula at Stanford University, MIT, Harvard University, Princeton University, and Yale University.
The method was published by Robert C. Prim in 1957 building on ideas circulating in engineering groups at Bell Labs, and it was independently discovered by others including contributors associated with Zellweger Analytics and earlier notes in military research contexts related to United States Department of Defense projects. Prim's method is closely related to Kruskal's algorithm, developed by Joseph Kruskal and taught alongside it in courses at Harvard University and Princeton University. It also connects to Borůvka's algorithm from 1926, which originated in Czech Technical University in Prague, and to matroid intersection results explored at Institute for Advanced Study and Courant Institute. Further theoretical connections link to shortest-path algorithms developed by Edsger Dijkstra and to flow algorithms studied at Stanford University and Rutgers University.
Category:Algorithms