Dijkstra’s algorithm
What is it?
Solves the single-source shortest path problem — find shortest path from one designated node to every other node.
Only works with non-negative edge weights.
Steps:
- Take the starting node
- Compute the distances to every other connected node (just follow the edges from the starting node)
- Take the smallest edge, and follow it to a new node
- Use the edges from the new node to update the table, and possibly create new/smaller paths to other nodes
- Take the new smallest edge to a node that was not visited yet
- Repeat from step 4
Methods: