# Dijkstra's Shortest Path Algorithm

1 min read

The Algorithm has 3 main steps:

- Find the nearest neighbor.
- Check whether there’s a cheaper path to neighbors of this node. If so, update costs.
- 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