NOTE 12 · ALGORITHMS · MAPS · OPENSTREETMAP

The flood and the arrow.

Watch a real Barcelona grid become a priced graph, flood with Dijkstra, aim with A*, collapse with hierarchy — every count computed live in your browser.

SEP 2026 ~13 MIN 5 SCENES + 1 SCOREBOARD MODE: COMPUTED LIVE
CÒRSEGA → SARDENYA · 3,464 M · 53 JUNCTIONS

01The question you're actually asking

Google says that every day, people drive more than a billion kilometers with Google Maps open, across more than 220 countries and territories. More than two billion people use it each month. Each of them, at some point, taps a dot and a destination — and a route appears, in a blink, priced in minutes.

Nothing about that blink is a lookup. There is no book of answers to consult: the possible routes between two points in a city are too many to enumerate, let alone store. What appears instead is a computation — run against a strange, stripped-down picture of the city, finished before you notice it started.

One honesty note before we start: Google has never published the algorithms inside its routing engine. What it publishes is the data side — live traffic, learned patterns, predicted arrival times. The machinery any router at this scale must run on, though, is public science, built in the open by researchers and by routing engines whose source you can read. So this page rebuilds that machinery in front of you, on a real place: the Eixample district of Barcelona, 1,281 intersections and 1,814 street segments from OpenStreetMap, embedded in this file. Every count you will see is computed by this page, in your browser, as you scroll — and the street you start on is called Còrsega, while the one you'll finish on is called Sardenya.

The map is not a picture. It is a question about a graph — and the whole engineering problem is answering it without reading the whole world.

This is a real slice of Barcelona — the Eixample — drawn from 1,814 real street segments. To your eyes, a drawing. To a router, neither.

A router keeps only the places where streets meet or end: 1,281 intersections. Each becomes a vertex — a dot with a position and nothing else.

Each stretch of street between two intersections becomes an edge. This one — Carrer de Còrsega leaving our origin — is 133 m long, and one-way.

Then every edge gets a price in seconds: length ÷ speed by street class. Avenues 50, side streets 40, residential 30, living streets 20 km/h — illustrative free-flow prices, ours, stated.

The question is set: the cheapest total price from Còrsega, bottom left, to Sardenya, top right — 2,459 m apart as the crow flies. Everything from here on is this one question.

02Dijkstra, before computers were ready

In 1956, Edsger W. Dijkstra wanted to show off a new computer by computing routes between Dutch cities. He told the story plainly, decades later: “What's the shortest way to travel from Rotterdam to Groningen? It is the algorithm for the shortest path, which I designed in about 20 minutes.” A café, his fiancée, no pencil. The algorithm was published in 1959, and it still works exactly as he drew it in his head.

Here is the whole idea. Hold every intersection at an estimated price of infinity, except the origin at zero. Then repeat one move forever: take the cheapest unsettled intersection and settle it — its estimate becomes final — and offer each of its neighbors a new estimate through it, keeping whichever route is cheaper. That offer is called a relaxation, and it is the only way information moves.

Two properties make this the reference solution. Settled means settled: no later discovery can improve a settled price, because any alternative route must arrive through something more expensive first. And it works whenever prices don't go negative — travel times never do. What Dijkstra's algorithm gives you is not just an answer but a proof: when your destination settles, no cheaper route exists. The question is what that proof costs to run.

Start at Còrsega with price zero; every other intersection starts at infinity. The rule never changes: settle the cheapest unsettled vertex.

Each settlement is permanent, and it re-prices that intersection's neighbors. Growth follows one law: by price, in every direction.

Watch what the search does not know: where you are going. The flood spends real work behind you and sideways from you — streets no route to Sardenya could ever use.

Before Sardenya settles, the search has settled 1,123 of the 1,281 intersections — 88% of the neighborhood, to answer one question.

Sardenya settles at 3,464 m, 4.4 minutes — provably the cheapest. Now scale the same flood to an 18-million-vertex Europe: it reads 9.3 million vertices per query. Correct, and far too slow.

Change nothing about the search. Add one number per intersection: a lower bound on time-to-go — straight-line distance ÷ 50 km/h, the fastest price on this map. This is A*, from 1968.

The bound is admissible: it can never overestimate, because no street beats the fastest street. So the queue may prefer intersections that make progress — it just can't lie.

The flood collapses into a corridor. Behind it, the ghost: everything Dijkstra read that A* never touches.

311 settled instead of 1,123 — 3.6× less work — and the route is identical: 3,464 m, 4.4 min. The optimality proof survives.

But a corridor still widens with distance. Across a continent, straight-line bounds leave millions of intersections in the search. The next idea stops aiming at the map — and rewrites the map itself.

Correct was never the problem.
Fast was.

03The skeleton of a continent

Road networks are not flat. A 2015 survey of the field puts it in one sentence: “Sufficiently long shortest paths eventually converge to a small arterial network of important roads.” That is not an accident — it is what motorways and avenues are for. Any route far enough from its ends lives almost entirely on the skeleton.

Production routers exploit this openly. Valhalla, an open routing engine, stores the world at three levels: motorways, trunks and primaries at the top; secondary and tertiary streets in the middle; residential streets at the bottom. A long query climbs to the coarse level, crosses, and descends — most of the city never enters the search at all.

In 2008, Robert Geisberger, Peter Sanders, Dominik Schultes and Daniel Delling turned the idea into a theorem-grade machine: Contraction Hierarchies. Instead of trusting road classes — a human label — preprocessing computes each intersection's importance from the map's own shortest paths, then removes the unimportant ones, bridging their neighbors with shortcuts. Minutes of preprocessing buy queries that touch a few hundred intersections. On a continent. The scoreboard below shows what that is worth.

Our route already knows about the skeleton: 85% of its length is arterial. Long answers don't live on side streets.

Open engines bake this in: Valhalla keeps motorways and primaries at level 0, secondaries at 1, residential at 2 — search coarse first, descend at the ends.

Model it here: local streets exist only within 400 m of origin and destination. The search settles 428 instead of 1,123 — same optimal route, in this demo. But pruning by class has no guarantee in general.

Contraction Hierarchies earn the guarantee: importance is computed from the map's own shortest paths, then unimportant intersections are contracted away — neighbors bridged by shortcuts.

A query then runs up, across, down: locals to the skeleton, skeleton to the destination's exit. Continental queries settle hundreds, not millions — the scoreboard is next.

ACT 05 THE SCOREBOARD WESTERN EUROPE · 18.0 M VERTICES
9,326,696
VERTICES SCANNED PER QUERY — DIJKSTRA, 1959
SAME GRAPH
SAME ANSWER→SAME PROOF
280
VERTICES SCANNED PER QUERY — CH, 2008
METHODSCANNED / QUERYAVG TIMEPREPROCESSSPACE
Dijkstra9,326,6962,195,080 µs—0.4 GiB
Bidirectional Dijkstra4,914,8041,205,660 µs—0.4 GiB
CRP (re-priceable)2,7661,650 µs1 h0.9 GiB
Contraction Hierarchies280110 µs5 min0.4 GiB
Transit-node routing—2.09 µs22 min2.5 GiB
Hub labels—0.56 µs37 min18.8 GiB

PER-QUERY AVERAGES ON THE STANDARD WESTERN EUROPE ROAD NETWORK BENCHMARK — 18.0 MILLION VERTICES, 42.5 MILLION DIRECTED ARCS, TRAVEL-TIME COSTS, RANDOM POINT-TO-POINT QUERIES, SINGLE THREAD. SOURCE: BAST, DELLING, GOLDBERG, MÜLLER-HANNEMANN, PAJOR, SANDERS, WAGNER AND WERNECK, “ROUTE PLANNING IN TRANSPORTATION NETWORKS” (2015), TABLE 1. THE RATIOS ABOVE ARE COMPUTED BY THIS PAGE FROM THOSE PUBLISHED NUMBERS.

04Prices that breathe

Everything so far assumed one price list. Real routers live with a new one every few minutes. Google describes its own system plainly: live conditions come from aggregate location data of people driving — not sensors — and future conditions come from machine learning that blends live traffic with years of patterns: the same freeway holds 65 km/h at 7 a.m. and 15 at 5 p.m., and the model knows both. Road quality, closures, tolls and driver reports adjust prices too, before any search runs.

The prediction layer is where the engineering turned openly modern. Google and DeepMind split the world's roads into Supersegments — chains of segments that share traffic — and train a graph neural network that predicts the travel time of each: terabytes of traffic in, one model for all of them. Google says its arrival estimates have been consistently accurate for over 97% of trips, and that the partnership cut the remaining misses by up to half in cities like Berlin, Tokyo and São Paulo. Those are Google's own numbers about itself — but the mechanism is published, and it is a graph, again.

The routing machinery is built for this. Research systems like CRP — customizable route planning, from Microsoft, run in production at Bing — separate the map's structure from its metric, so a whole continent can be re-priced for new traffic in minutes without rebuilding anything. OSRM, the open router, ships the same idea as an option. Re-pricing is not an afterthought in this world; it is the design center.

Same graph, same request. But the spine of our route — Carrer del Rosselló, 1,104 m of it — jams. We price it ×2.5: an illustrative jam, ours, stated.

Nothing reruns the world. The search reads the same streets with new numbers — and the old route now costs 6.4 minutes instead of 4.4.

So the line moves. Rosselló drops from 1,104 m of route to 135 m; Carrer de València, one block south, carries 2,276 m. Same origin, same destination, new best answer.

Notice the search itself worked harder: 1,037 settled instead of 311. When prices defy distance, aiming gets weaker — the bound still holds, but it says less.

In production the new price list arrives continuously — crowdsourced conditions, learned patterns, driver reports — and the blue line quietly steps around a jam that hasn't started yet.

05The answer, in order

Put the whole machine back together. A city becomes a graph: dots and priced lines. A correct search — Dijkstra's flood — settles it nearest-first and proves its answer, at a cost that grows with the world. An admissible bound — the arrow — collapses the flood into a corridor without touching the proof. The map's own hierarchy, contracted and preprocessed, shrinks a continent to a few hundred touches per query. And traffic enters not as a new mechanism but as a new price list, arriving continuously, learned from the cars ahead of you.

None of this needs a data center the size of a continent, by the way. A street graph is small enough to live in your pocket: Google Maps can guide an offline route entirely on your phone, as long as the whole route fits inside the saved area — no live traffic, no alternatives, just the graph and the search, on their own. (Where the blue dot on that map comes from is its own story.)

And the honest boundary, one last time: Google has never published the exact algorithm behind its blue line. It doesn't need to — the physics are public. Every fast router you can read — Valhalla, OSRM, GraphHopper, running today on OpenStreetMap's commons of 10.8 billion mapped nodes — answers with the ideas you just watched: aim the search, honor the skeleton, precompute what the world will ask, re-price when it changes. The next time the line appears in a blink, you know what that blink cost, and when it was paid for.

A route is a question about a priced graph. The blink of the answer was paid for in advance — hours of preparation for every millisecond of asking.
DATA — THE STREET GRAPH IS A REAL OPENSTREETMAP EXTRACT OF BARCELONA'S EIXAMPLE (© OPENSTREETMAP CONTRIBUTORS, ODbL, SNAPSHOT 2026-08-21), EMBEDDED IN THIS FILE: 1,281 INTERSECTIONS, 1,814 SEGMENTS. FREE-FLOW SPEEDS BY STREET CLASS ARE ILLUSTRATIVE AND LABELED AS SUCH. EVERY COUNT, LENGTH, AND TIME ON THIS PAGE IS COMPUTED BY THE PAGE FROM THAT EMBEDDED DATA — VERIFIED OFFLINE BY THE SAME ENGINE AT BUILD TIME. SOURCES — E. W. DIJKSTRA, “A NOTE ON TWO PROBLEMS IN CONNEXION WITH GRAPHS” (1959); HART, NILSSON & RAPHAEL, “A FORMAL BASIS FOR THE HEURISTIC DETERMINATION OF MINIMUM COST PATHS” (1968); GEISBERGER, SANDERS, SCHULTES & DELLING, “CONTRACTION HIERARCHIES” (2008); BAST ET AL., “ROUTE PLANNING IN TRANSPORTATION NETWORKS” (2015); VALHALLA DOCUMENTATION; GOOGLE & DEEPMIND PUBLISHED BLOGS ON TRAFFIC AND ETA PREDICTION.