Eroxl's Notes
Prim's Algorithm

Prim's algorithm is a greedy algorithm that finds a minimum spanning tree for a connected, weighted graph. The algorithm starts at an arbitrary node adding the cheapest possible connection from the tree to another non-tree vertex at every step.

The algorithm performs the following steps:

  1. Initialize a tree with a single vertex, chosen arbitrarily from the graph.
  2. Grow the tree by one edge: Of the edges that connect the tree to vertices not yet in the tree, find the minimum-weight edge, and transfer it to the tree.
  3. Repeat step 2 (until all vertices are in the tree).