Prim's Algorithm

What is Prim's Algorithm?

Prim's Algorithm is used to find a minimum spanning tree in a connected, weighted, undirected graph.

How It Works

  1. Choose any vertex to start.
  2. Find the lowest-weight edge connecting the tree to a new vertex.
  3. Add that edge and vertex to the tree.
  4. Repeat until all vertices are included.

Example

Diagram demonstrating Prim's Algorithm

Learn more about Prim's Algorithm