# Prim's Algorithm

## The Steps For Implementing Prim's Algorithm

- Determine the arbitrary starting point
- For each edge coming out of the node, add it to a priority queue based on weight
- While the priority queue is not empty, remove the edge with the least weight
- If the end node of the edge has not yet been visited, mark it as visited and add the edge to the tree
- If the step above was completed(meaning the end node hadn't been visited before), insert all outgoing edges from the current node to unvisited nodes
- Repeat the above 2 steps until the priority queue is empty

Link for More on Prim's and Example