How sat-nav and online maps calculate routes and traffic
TUREFF• •0
You type in a destination and, within a second, your map app offers a route, an arrival time and perhaps a warning about a jam ahead. Behind that simple screen is a combination of map data, graph algorithms and a great deal of anonymised traffic information. Understanding the basics helps you judge when to trust the suggestion and when to ignore it.
The road network as a graph
To a routing engine, the road map is a graph: junctions are points (nodes) and stretches of road between them are links (edges). Each edge carries information such as:
- Length and speed limit or typical speed.
- Restrictions: one-way streets, banned turns, low bridges, weight limits, private roads and toll roads.
- Road class: motorway, main road, residential street or track.
- Turn costs: turning across traffic or at lights takes longer than going straight on.
Each edge gets a cost, usually the expected travel time. The best route is the path from start to finish with the lowest total cost.
Finding the best path quickly
The classic method is Dijkstra's algorithm, which explores outwards from the start, always extending the cheapest path found so far until it reaches the destination. A refinement called A-star uses an estimate of the remaining distance to steer the search towards the goal, so it explores far less of the map.
A national road network has millions of junctions, so real services add pre-processing. Techniques such as contraction hierarchies calculate shortcuts through the network in advance, so that a long journey can skip quickly along the major roads instead of checking every side street. This is why a cross-country route appears almost instantly.
Where traffic information comes from
- Anonymised location data from phones using the app, and sometimes from connected cars and fleet vehicles. If many devices on a road are moving slowly, the road is probably congested.
- Road sensors and official feeds from transport authorities, covering incidents, closures and roadworks.
- User reports of accidents, hazards and speed cameras in some apps.
- Historical patterns: typical speeds for each road by time of day and day of the week. These matter most for a journey you plan for later, because nobody can measure future traffic directly.
The app blends live and historical data to predict how fast each road will be when you actually reach it, not just how fast it is now. That prediction is the basis of the estimated arrival time.
Why routes change mid-journey
Most apps keep recalculating as conditions change. If a faster alternative appears, the app may offer it or switch automatically. This can be genuinely useful, but there are side effects:
- Rat-runs: many drivers being sent down the same quiet residential street can create a new jam there.
- Small savings: a reroute to save a minute or two may mean narrower or more complicated roads.
- Sudden changes: incident data can arrive late, so the app reacts after you have passed the last exit.
Settings worth checking
- Avoid tolls, motorways or ferries if you prefer.
- Vehicle type: some apps can route for a motorbike, a large vehicle or an electric car with charging stops.
- Walking and cycling: these use different networks, including paths and cycle lanes, and different costs such as hills.
- Departure time: setting a future start time makes the app use historical patterns for its estimate.
When to trust your own judgement
Map data can lag behind reality: a new road layout, a closed bridge or a farm track marked as a road. Always follow road signs and local restrictions over the screen, especially for large vehicles and on rural or mountain roads. If a route looks odd, compare it with the alternatives the app offers, or zoom out and check it against what you know of the area.
Has a sat-nav ever sent you somewhere ridiculous, or saved you from a jam? Share the story in the comments.