Google Maps is unreasonably fast. Let me explain
Veritasium · 29:54 · 1 months ago
Mapping apps achieve instant routing by using a hierarchy of roads and pre-calculated shortcuts, which allows them to ignore unnecessary turns and focus only on the most efficient paths across a network of millions of intersections.
-
Computational limits — Calculating every possible route on a continental map would involve trillions of combinations and take centuries to solve by brute force .
-
Dijkstra’s Algorithm — This foundation method searches for the optimal path by radiating outward in all directions equally, which is mathematically sound but too slow for large-scale navigation .
-
Directional guidance — The A-Star algorithm improves upon basic searches by adding a heuristic that prioritizes nodes closer to the destination, effectively pointing the process toward the goal .
-
Customizable Contraction Hierarchies — Modern systems organize the road network into a hierarchy of importance, allowing the software to jump between major highways rather than checking every local street .
-
Three-phase process — To maintain speed while keeping data current, the system splits work into distinct stages:
- Node ranking — Identifying critical intersections and bridges to create shortcuts that bypass lower-level roads .
- Traffic updates — Recalculating the costs of those shortcuts when road conditions or closures change .
- Rapid querying — Executing the final search, which relies on the pre-made shortcuts to return results in mere microseconds .
-
Why does adding shortcuts to a map prevent the algorithm from missing the shortest path?