e01.org

Prim's algorithm

In computer science, Prim's algorithm is a greedy algorithm that finds a minimum spanning tree for a weighted undirected graph. This means it finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized. The algorithm operates by building this tree one vertex at a time, from an arbitrary starting vertex, at each step adding the cheapest possible connection from the tree to another vertex. The algorithm was developed in 1930 by Czech mathematician Vojtěch Jarník and later rediscovered and republished by Joseph Kruskal in 1956, Robert C. Prim in 1957, and Edsger W. Dijkstra in 1959. Therefore, it is also sometimes called Jarník's algorithm, the Prim–Jarník algorithm, the Prim–Dijkstra algorithm or the DJP algorithm. Other well-known algorithms for this problem include Kruskal's algorithm and Borůvka's algorithm. These algorithms find the minimum spanning forest in a possibly disconnected graph; in contrast...

In computer science, Prim's algorithm is a greedy algorithm that finds a minimum spanning tree for a weighted undirected graph. This means it finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized. The algorithm operates by building this tree one vertex at a time, from an arbitrary starting vertex, at each step adding the cheapest possible connection from the tree to another vertex. The algorithm was developed in 1930 by Czech mathematician Vojtěch Jarník and later rediscovered and republished by Joseph Kruskal in 1956, Robert C. Prim in 1957, and Edsger W. Dijkstra in 1959. Therefore, it is also sometimes called Jarník's algorithm, the Prim–Jarník algorithm, the Prim–Dijkstra algorithm or the DJP algorithm. Other well-known algorithms for this problem include Kruskal's algorithm and Borůvka's algorithm. These algorithms find the minimum spanning forest in a possibly disconnected graph; in contrast, the most basic form of Prim's algorithm only finds minimum spanning trees in connected graphs. However, running Prim's algorithm separately for each connected component of the graph, it can also be used to find the minimum spanning forest. In terms of their asymptotic time complexity, these three algorithms are equally fast for sparse graphs, but slower than other more sophisticated algorithms. However, for graphs that are sufficiently dense, Prim's algorithm can be made to run in linear time, meeting or improving the time bounds for other algorithms. Let Y 1 be a minimum spanning tree of graph P. If Y 1 =Y then Y is a minimum spanning tree. Otherwise, let e be the first edge added during the construction of tree Y that is not in tree Y 1 , and V be the set of vertices connected by the edges added before edge e. Then one endpoint of edge e is in set V and the other is not. Since tree Y 1 is a spanning tree of graph P, there is a path in tree Y 1 joining the two endpoints. As one travels along the path, one must encounter an edge f joining a vertex in set V to one that is not in set V. Now, at the iteration when edge e was added to tree Y, edge f could also have been added and it would be added instead of edge e if its weight was less than e, and since edge f was not added, we conclude that w(f) \ge w(e). Let tree Y 2 be the graph obtained by removing edge f from and adding edge e to tree Y 1 . It is easy to show that tree Y 2 is connected, has the same number of edges as tree Y 1 , and the total weights of its edges is not larger than that of tree Y 1 , therefore it is also a minimum spanning tree of graph P and it contains edge e and all the edges added before it during the construction of set V. Repeat the steps above and we will eventually obtain a minimum spanning tree of graph P that is identical to tree Y. This shows Y is a minimum spanning tree. The minimum spanning tree allows for the first subset of the sub-region to be expanded into a larger subset X, which we assume to be the minimum.

References

  1. ^ Jarník, V. (1930), "O jistém problému minimálním" [About a certain minimal problem], Práce Moravské Přírodovědecké Společnosti (in Czech), 6 (4): 57– 63, hdl : 10338.dmlcz/500726 . Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
  2. ^ Kepner, Jeremy; Gilbert, John (2011), Graph Algorithms in the Language of Linear Algebra , Software, Environments, and Tools, vol. 22, Society for Industrial and Applied Mathematics , p. 55, ISBN 9780898719901 . Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
  3. ^ Johnson, Donald B. (December 1975), "Priority queues with update and finding minimum spanning trees", Information Processing Letters , 4 (3): 53– 57, doi : 10.1016/0020-0190(75)90001-0 . Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
  4. ^ Quinn, Michael J.; Deo, Narsingh (1984), "Parallel graph algorithms", ACM Computing Surveys , 16 (3): 319– 348, doi : 10.1145/2514.2515 , S2CID 6833839 Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
  5. ^ Setia, Rohit (2009), "A new parallel algorithm for minimum spanning tree problem" (PDF) , Proc. International Conference on High Performance Computing (HiPC) Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
  6. ^ Kruskal, J. B. (1956). "On the shortest spanning subtree of a graph and the traveling salesman problem" . Proceedings of the American Mathematical Society . 7 (1): 48– 50. doi : 10.1090/S0002-9939-1956-0078686-7 . JSTOR 2033241 . Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
  7. ^ Prim, R. C. (November 1957), "Shortest connection networks And some generalizations" , Bell System Technical Journal , 36 (6): 1389– 1401, Bibcode : 1957BSTJ...36.1389P , doi : 10.1002/j.1538-7305.1957.tb01515.x . Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
  8. ^ Dijkstra, E. W. (December 1959), "A note on two problems in connexion with graphs" (PDF) , Numerische Mathematik , 1 (1): 269– 271, doi : 10.1007/BF01386390 , S2CID 123284777 . Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
  9. ^ Sedgewick, Robert ; Wayne, Kevin Daniel (2011), Algorithms (4th ed.), Addison-Wesley, p. 628, ISBN 978-0-321-57351-3 . Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
  10. ^ Rosen, Kenneth (2011), Discrete Mathematics and Its Applications (7th ed.), McGraw-Hill Science, p. 798 . Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
  11. ^ Tarjan, Robert Endre (1983), "Chapter 6. Minimum spanning trees. 6.2. Three classical algorithms", Data Structures and Network Algorithms , CBMS-NSF Regional Conference Series in Applied Mathematics, vol. 44, Society for Industrial and Applied Mathematics , pp. 72– 77 . Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
  12. ^ a b Cheriton, David ; Tarjan, Robert Endre (1976), "Finding minimum spanning trees", SIAM Journal on Computing , 5 (4): 724– 742, doi : 10.1137/0205051 , MR 0446458 . Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
  13. ^ a b c Grama, Ananth; Gupta, Anshul; Karypis, George; Kumar, Vipin (2003), Introduction to Parallel Computing , Addison-Wesley, pp. 444– 446, ISBN 978-0201648652 Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
  14. ^ a b Pettie, Seth; Ramachandran, Vijaya (January 2002), "An optimal minimum spanning tree algorithm" (PDF) , Journal of the ACM , 49 (1): 16– 34, doi : 10.1145/505241.505243 , MR 2148431 , S2CID 5362916 . Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
  15. ^ a b Tarjan (1983) , p. 77. Wikipedia revision 1368985795, retrieved 2026-11-18 · 1794956400.0
source: e01 Encyclopedia · licence: CC BY-SA 4.0 · page · source revision

Cite this

"Prim's algorithm". 1786507159. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1368985795

JSON record · API collection · citation policy