Prim's Algorithm
What is Prim's Algorithm?
Prim's Algorithm is a greedy algorithm that finds the Minimum Spanning Tree (MST)
for a weighted, undirected, and connected graph. It works by repeatedly selecting
the lowest-weight edge that connects the existing tree to a new vertex. In short,
it chooses the cheapest available edge that expands the tree.
How Does Prim's Algorithm Work?
- Start with any vertex in the graph.
- Look at the edges connecting the existing tree to vertices outside the tree.
- Choose the edge with the smallest weight.
- Add the edge and its new vertex to the tree.
- Repeat until every vertex is included in the tree.
Learn More
Learn more about Prim's Algorithm here