What:

A highly efficient shortest-path-finding greedy algorithm. Used in Google Maps etc.

The Goal:

  • Input: A directed graph and a designated node (starting node) in . Assume every node in is reachable from . We’re also given length for ever edge in . (A fully connected graph basically)
  • Output: For every node in , a shortest path from . (I.E. A list of paths.)

How it works:

  • Idea: Constantly maintain a set of nodes for which we’ve the shortest path from .
    • is the explored part insofar.
  • Mathematical Greedy Criteria: , where
    • Simple Terms: At each step / node, the shortest path from to : Choose the node that’s closest to you (minimises the path to where you are + the possible paths around you).
    • In even simpler terms: At each step, analyse ever node directly neighbouring your known paths. Jump to the closest node (from any known node in your set of distances) and update the list of paths you have to include that node.

Example:

  • In this iteration, we could jump to either , (two different ways) or .
  • To minimise distance travelled, we go to either (through ) or .
  • We’d thus add either one to the list of paths.

Getting Actual Paths:

As is, we’ve a list of lengths of paths. To get paths, we simply have to record the edge (the last node) that led us to explore this current node. So you backtrack hopping from node to its respective node that led to it.