Dijkstra's Shortest Path Algorithm

1 min read

The Algorithm has 3 main steps:

  1. Find the nearest neighbor.
  2. Check whether there’s a cheaper path to neighbors of this node. If so, update costs.
  3. Repeat until you’ve done this for every node.

Instead of a direct route, the shortest path is over different cities.

Dijkstra’s Algorithm works with bidirected or undirected graphs.

It works with positive weights.

If you have negative weights, use Bellman-Ford Algorithm.

September 24, 2018