Prim's Algorithm

This page outlines Prim's Algorithm, an algorithm that finds the minimum spanning tree of a graph.

Steps of Prim's Algorithm:

  1. Mark start node v as visited.
  2. Add v's outgoing edges to a priority queue.
  3. While the queue is not empty, repeat steps 4-8.
  4. Remove the smallest edge in the queue.
  5. If the node u at the end of this edge is unvisited, do steps 6-8.
  6. Mark u as visited.
  7. Add u to the spanning tree.
  8. Insert u's outgoing edges into the queue.

To learn more, visit this Wikipedia page.