We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Dijkstra's Algorithm Review

  • Again, Dijkstra's algorithm starts at a source node and traverses the graph to find the shortest path to a destination node.
  • The algorithm keeps track of the "shortest distance so far" while it travels, updating this each time it finds a shorter path.
  • Once all of a node's neighbors have been checked and their distances have been updated, that node is marked as visited.
  • At each step, the algorithm moves to the nearest unvisited neighbor with the shortest known distance. This repeats until the destination node is reached and its shortest path is determined.
  • Depending on where the source and destination nodes are – and on the implementation of the algorithm – it may need to traverse the entire graph to find the shortest path.