How does a map app decide the fastest route?
A map app decides which route to suggest by giving every road a cost, such as the minutes it should take to drive it right now. It adds up the costs along the possible routes and picks the lowest total. Live traffic changes those minutes, so the best route can change during the trip.
In one line: A program that gives every road a cost, such as travel time, and finds the route from start to finish with the lowest total.
Last reviewed: 25 October 2026 3 min read
What decision does it make?
You choose where to start and where to go. The app has to choose one path through all the roads in between. The shortest path is not always the fastest, because some roads are busy or slow.
| Decision | Possible answers |
|---|---|
| Which route is fastest? | One of many possible routes. The app suggests the one with the lowest total cost. |
What does it look at?
- The road map. Every crossing is a point and every road between two crossings is a line, including which roads are one-way.
- Length of each road. A longer road usually costs more than a shorter one.
- Live traffic. Phones running navigation apps can report how fast traffic is moving on each stretch of road.
- Crashes and closures. Reports of crashes, stalled cars and road hazards can make a road cost much more.
- Tolls. Some roads cost money to drive on, and that can be counted as part of the cost.
How does it learn the rule?
- Turn roads into a map of points and lines. Crossings become points. Roads become lines that join them.
- Give every road a cost. The cost can be distance, minutes in traffic, tolls or a mix of these.
- Search outward from the start. The program checks the nearest crossings first, then the next nearest, always keeping the cheapest way it has found to each one, until it reaches the finish.
- Update the costs. New traffic reports keep arriving, so the costs change and the best route can change too.
Where can it go wrong?
- Traffic changes after you leave. A road that was clear when the route was chosen can jam a few minutes later.
- Not enough reports. On quiet roads, fewer phones report their speed, so the traffic guess is less sure.
- A closure nobody has reported yet. If the map does not know about it, the route may lead straight to it.
Try it
Toy example: four routes to the same place. Change how much the app cares about minutes, turns and tolls, and see which route it picks.
Toy example: four routes with made-up minutes, number of turns and tolls in dollars.
| Item | Values | Score at starting weights |
|---|---|---|
| Route A: highway with a toll | Minutes: 18; Turns: 3; Tolls: 4 | 57 |
| Route B: main streets | Minutes: 22; Turns: 6; Tolls: 0 | 72 |
| Route C: back roads | Minutes: 25; Turns: 9; Tolls: 0 | 84 |
| Route D: shortest distance, but a traffic jam | Minutes: 30; Turns: 4; Tolls: 0 | 94 |
Check it
What does a map app add up to choose a route?
Answer: The cost of each road along the route. It adds the cost of every road on a route and picks the lowest total.
Why is the shortest route not always the fastest?
Answer: Traffic can make a short road slow. Minutes in traffic can matter more than distance.
A crash is reported on your route. What can happen?
Answer: That road costs more, so another route may win. New reports change the costs, and the best route can change.
For older readers
This is a shortest-path problem on a weighted graph. Intersections are vertices, roads are edges (one-way roads are directed edges), and each edge has a weight such as distance, travel time or toll. A classic method is Dijkstra's algorithm, which explores vertices in order of their distance from the start and works when no weight is negative. Speed-ups such as bidirectional search and goal-directed search (A*) visit fewer vertices in practice. Live traffic data from many travelers is called crowdsourced or probe data.
Questions
New traffic or crash reports changed the cost of the roads ahead, so a different route now had the lowest total.
Phones running navigation apps can share how fast they are moving, and people can report crashes and hazards. Many reports together show where traffic is slow.
It is the best the app can find with what it knows. If traffic changes or a road closes without a report, another route may turn out faster.
Sources
- University algorithms course: shortest paths, introduction (lecture notes) (opens another website)
- University algorithms course: Dijkstra's algorithm (lecture notes) (opens another website)
- Federal Highway Administration: crowdsourcing for transportation operations, questions and answers (opens another website)
- University algorithms course: speeding up shortest-path search (lecture notes) (opens another website)