Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Finding your way
A map app finds the quickest route among millions of roads in a blink. It doesn’t try every route. It explores outward from you, always extending the cheapest partial route found so far, and if it’s clever it leans toward the destination. A rover crossing Mars, a robot in a warehouse and a packet crossing the internet all solve the same problem: the shortest path in a graph.
Planetary rovers plan routes around rocks and slopes; warehouse robots, drones and game characters use A*. Network routing (OSPF uses Dijkstra), logistics, and the planning layer of almost every autonomous system rely on shortest-path algorithms. Choosing the right one can mean milliseconds instead of minutes on board.
- 1. A shortest-path algorithm finds…
- 2. A* is faster than plain Dijkstra because it…
- 3. If two parts of a map aren't connected, the path cost is…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Definitions
- A walk is a sequence of adjacent vertices; a path repeats no vertex; a cycle returns to its start.
- A graph is connected if every pair has a path.
- Components are the maximal connected pieces. Find them with BFS/DFS or union-find (near-constant time per operation).
Breadth-first search
BFS explores in layers: all vertices at distance 1, then 2, … In unweighted graphs, it gives fewest-edge paths in .
Dijkstra’s algorithm
For non-negative weights: keep tentative distances, repeatedly finalize the closest unfinished vertex, and relax its edges (). With a binary heap it runs in (Dijkstra, 1959).
- 1. BFS finds shortest paths when…
- 2. Dijkstra requires weights that are…
- 3. Relaxing edge (u, v) means…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.The shortest-path toolbox
| Algorithm | Handles | Cost |
|---|---|---|
| BFS | unit weights | O(n + m) |
| Dijkstra | weights ≥ 0 | O((n + m) log n) |
| Bellman–Ford | negative weights, detects negative cycles | O(nm) |
| Floyd–Warshall | all pairs | O(n³) |
| A* | weights ≥ 0 plus an admissible heuristic | ≤ Dijkstra, often far less |
A* search
Order the frontier by , where g is the cost so far and h estimates the cost to the goal. If h is admissible (never overestimates), A* returns an optimal path. If h is also consistent (), no vertex needs re-expansion. On grids with step cost ≥ 1, the Euclidean or octile distance is admissible. Weighted A* uses : fewer expansions, and the cost is at most optimal.
Negative weights
Negative weights arise with rewards, energy regeneration or log-probability costs. Dijkstra’s “finalize the closest” logic breaks. Bellman–Ford relaxes all edges n − 1 times. A further improvement after that reveals a negative cycle, where “shortest” is undefined.
- 1. An admissible heuristic…
- 2. Weighted A* with ε = 1.5 returns a path costing at most…
- 3. Bellman–Ford detects a negative cycle if…
Level 3: Advanced
★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.Correctness of Dijkstra
Invariant: when u is finalized, d(u) is the true distance. Suppose not. Take the true shortest path to u, and let y be its first unfinalized vertex, with predecessor x finalized. Then (non-negative weights). So y would have been chosen before u. Contradiction. ∎
A* optimality with an admissible h
When the goal t is popped with , every frontier node v has . Some frontier node lies on an optimal path with . So . ∎
Bellman–Ford
A shortest path without negative cycles has at most n − 1 edges. After round k, all shortest paths using ≤ k edges are correct (induction). ∎
Exercise 3.1: Dijkstra on 0→1 (4), 0→2 (1), 2→1 (2), 1→3 (1), 2→3 (5)
Finalize 0 (0), then 2 (1). Relaxing gives d(1) = 3 and d(3) = 6. Finalize 1 (3), and relaxing gives d(3) = 4. Finalize 3 (4).
- 1. Dijkstra's proof relies on…
- 2. A shortest simple path has at most how many edges?
- 3. d(3) in the exercise:
Level 4: Expert
★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.Planning a rover traverse
A 60 × 60 grid map has 18% rock cells (impassable) and a crater rim that costs up to 3× to cross, with 8-connected moves. All three planners use the same cost model:
| Planner | Path cost | Cells expanded |
|---|---|---|
| Dijkstra | 93.5 | 2921 |
| A* (octile heuristic) | 93.5 | 761 (4× fewer) |
| weighted A* (ε = 2) | 105, 12% worse | 70 |
The heuristic is admissible because every cell costs at least 1. Mars rover planners have used related graph-search methods: GESTALT on Spirit and Opportunity evaluates arcs on a terrain grid (Biesiadecki and Maimone, 2006), and Field D* replans efficiently as new terrain is seen (Ferguson and Stentz, 2006).
Shortest paths in AI, robotics and aerospace
- Planetary rovers: GESTALT and AutoNav on MER, MSL and Mars 2020; Field D* and incremental replanning (D* Lite).
- Networks: OSPF link-state routing (Dijkstra); delay-tolerant networking for deep-space relays (contact graph routing).
- Robot motion planning: graph search over lattices and PRM/RRT roadmaps; optimal graph search in configuration space.
- Learning: neural heuristics for A*; differentiable shortest paths in structured prediction.
References
- E. Dijkstra (1959). “A note on two problems in connexion with graphs.” Numerische Mathematik, 1.
- P. Hart, N. Nilsson, B. Raphael (1968). “A formal basis for the heuristic determination of minimum cost paths.” IEEE Trans. Systems Science and Cybernetics, 4(2).
- R. Bellman (1958). “On a routing problem.” Quarterly of Applied Mathematics, 16.
- T. Cormen, C. Leiserson, R. Rivest, C. Stein (2022). Introduction to Algorithms, 4th ed. MIT Press. Ch. 22–23.
- D. Ferguson, A. Stentz (2006). “Using interpolation to improve path planning: the Field D* algorithm.” J. Field Robotics, 23(2).
- J. Biesiadecki, M. Maimone (2006). “The Mars Exploration Rover surface mobility flight software: driving ambition.” IEEE Aerospace Conference.
- S. Koenig, M. Likhachev (2002). “D* Lite.” AAAI.
- S. LaValle (2006). Planning Algorithms. Cambridge. Ch. 2.