Please note that the content of this book primarily consists of articles
available from Wikipedia or other free sources online. In computer
science, Prim's algorithm is an algorithm that finds a minimum spanning
tree for a connected 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. Prim's
algorithm is an example of a greedy algorithm. The algorithm was
developed in 1930 by Czech mathematician Vojt¿ch Jarník and later
independently by computer scientist Robert C. Prim in 1957 and
rediscovered by Edsger Dijkstra in 1959. Therefore it is also sometimes
called the DJP algorithm, the Jarník algorithm, or the Prim-Jarník
algorithm. The only spanning tree of the empty graph (with an empty
vertex set) is again the empty graph. The following description assumes
that this special case is handled separately. The algorithm continuously
increases the size of a tree, one edge at a time, starting with a tree
consisting of a single vertex, until it spans all vertices.