AlgoViz

Dijkstra's algorithm

medium 22 min

Dijkstra's algorithm finds the shortest distance from one source to every node of a graph whose edge weights are non-negative.

Where it shows up

The same pattern appears across everyday software.

  • GPS and map routing

    Navigation apps model intersections as nodes and road segments as edges weighted by travel time. Dijkstra is the foundation; production systems speed it up with A* (a distance-to-goal estimate), bidirectional search and precomputed shortcuts such as contraction hierarchies.

  • Internet routing protocols

    Link-state protocols such as OSPF and IS-IS flood the network map to every router, and each router runs Dijkstra's shortest path first (SPF) computation to build its forwarding table.

  • Games and robotics

    Characters and robots find paths over grids or navigation meshes where terrain has different costs (road, mud, water). Dijkstra and its goal-directed cousin A* are the standard tools.

  • Logistics and delivery

    Warehouse robots, delivery fleets and ride-hailing dispatch need the fastest route between many points; shortest-path computations on road graphs are the inner loop of their planners.

  • Flight and transit search

    Journey planners treat stops and departures as nodes and minimise travel time or price, with extra state (number of transfers, time of day) layered on top of the same relax-the-closest idea.