Prim's Algorithm
Minimum Spanning Tree Algorithm
More info: Prim's Algorithm for Minimum Spanning Tree (MST)
- Initialize a Priority Queue for the edges, with the edges weights as the key
- Mark the starting node as visited
- Insearch each outgoing edge for the starting node
- Loop until the queue is empty:
- Get the edge at the front of the queue
- If the end node is unvisited:
- Mark the end node as visited
- Add the end node to the storage of visited nodes
- Insert all edges that point toward unvisited nodes