Euclidean distance is useful because it is simple. But real journeys do not happen through empty geometric space. People travel on roads, footpaths, cycle lanes, and rail lines.
That is why many applied studies replace straight-line distance with network distance or network travel time.
1. Start with a simple example
Imagine a household and a supermarket.
- On the map, the store looks only 1.4 km away.
- But a railway line sits between home and the store.
- There is only one bridge crossing. So the actual driving route might be:
- home to local junction: 0.4 km
- local junction to bridge: 1.1 km
- bridge to store: 0.7 km That gives:
So the straight-line distance is 1.4 km, but the road-network distance is 2.2 km.
This is the basic idea of network distance:
- you cannot travel directly across the map
- you have to follow the available network
- barriers and crossings change the real route
2. Why this matters in a SIM
In a spatial interaction model, the value used for distance affects how attractive a store looks.
Suppose one neighbourhood is choosing between two stores.
| Store | Straight-line distance | Road distance | Travel time |
|---|---|---|---|
| Store A | 1.8 km | 3.0 km | 10 min |
| Store B | 2.2 km | 2.4 km | 6 min |
If the model uses Euclidean distance, Store A looks closer.
If the model uses road distance or travel time, Store B may be the better option.
So changing the distance measure can change the predicted market share of stores.
3. How network distance is calculated in practice
The idea is simpler than the technical language sometimes makes it sound.
To compute a network route, we usually do four things.
Step 1: Build or obtain a network
First, we need a road or path network.
That means the streets are stored as connected segments. Junctions need to join correctly, and one-way streets need to be recorded properly.
Step 2: Choose an edge weight
Next, we decide what each road segment should count as.
- If each segment is measured in metres, the result is network distance.
- If each segment is measured in minutes, the result is travel time.
- If extra penalties are added, the result can represent a broader travel cost.
Step 3: Snap origins and destinations to the network
Homes, postal-sector centroids, and stores usually do not sit exactly on a road segment in the data.
So they must be attached to the network first. This is often called snapping.
This matters because a bad snap can connect a location to the wrong road.
Step 4: Run a shortest-path algorithm
Finally, the computer searches the network and finds the best route between the origin and destination.
For one trip, that gives one route.
For a SIM, we usually repeat this many times and build an origin-destination table, showing the shortest route from every neighbourhood to every store.
4. What does “shortest path” mean?
The phrase shortest path just means:
- list the possible routes
- calculate the cost of each route
- keep the route with the lowest total cost If the cost is metres, we get the shortest distance.
If the cost is minutes, we get the fastest route.
That is exactly what navigation software does in everyday life. The software is not drawing a straight line. It is comparing allowed routes through a network.
5. Common routing algorithms
You do not need to know all the mathematics to understand the main idea. The important point is that different algorithms are just different ways for the computer to search the network efficiently.
Dijkstra’s algorithm
Dijkstra’s algorithm is the classic method.
It starts from the origin and keeps expanding to the next cheapest location until it reaches the destination.
It is a good teaching algorithm because the logic is clear.
Good points:
- guaranteed to find the shortest path
- conceptually clear Limitations:
- can be slower on very large networks If you want students to understand what routing is doing, Dijkstra is usually the best place to start.
A* algorithm
A* is similar, but smarter about where to search next.
It uses an estimate of how far the destination still is, often based on straight-line distance. That helps it move in the right general direction.
Good points:
- often faster than Dijkstra for point-to-point routing
- widely used in navigation and mapping tools Limitations:
- depends on a sensible heuristic If you want one route from one place to one other place, A* is often a practical choice.
Contraction Hierarchies
Large route systems, such as navigation apps, need to answer route questions very quickly.
A simple way to think about Contraction Hierarchies is this:
- the system prepares the road network in advance
- it stores useful shortcuts
- later, when a user asks for a route, the answer can be found much faster So instead of doing all the hard work at the moment you ask for directions, some of that work has already been done earlier.
Good points:
- extremely fast query performance after preprocessing
- well suited to repeated routing at scale Limitations:
- extra preparation is needed before routing starts
- harder to explain than Dijkstra or A* This is one reason navigation systems can return routes almost instantly, even on very large road networks.
For this course, the key idea is simple:
- Dijkstra is easiest to explain
- A* is often faster for one route
- Contraction Hierarchies are useful when a system has to answer many route queries
6. Network distance versus travel time
Network distance and travel time are related, but they are not the same.
For example:
- Route A is 4.0 km on a fast main road
- Route B is 3.0 km through slow local streets Route B is shorter.
But Route A may still be faster.
So:
- the shortest route is not always the fastest
- the fastest route is not always the shortest When modelling retail behaviour, travel time is often more realistic than length because people react strongly to delay and inconvenience.
7. Practical issues that affect routing
Real routing is shaped by more than geometry.
- One-way streets can make return trips different from outbound trips.
- Turn restrictions can prevent apparently obvious routes.
- Mode matters: a walking network, a driving network, and a cycling network are not the same.
- Time of day matters if congestion changes speeds.
- Missing bridges, tunnels, or crossings can greatly increase path length. These details explain why network analysis is more data-hungry than Euclidean calculation. The gain is realism, but the cost is complexity.
8. When should we use network distance in a SIM?
In a teaching spreadsheet, Euclidean distance is often enough because it is easy to reproduce and inspect.
In a more realistic retail model, network measures are often preferable when:
- route structure strongly affects accessibility
- barriers create large detours
- you want behaviourally plausible catchments
- the study will inform planning or forecasting decisions A useful compromise is to start with Euclidean distance to understand the model, then replace it with network distance or travel time once the logic is clear.
9. Final comparison
Suppose two stores are evaluated from the same neighbourhood.
| Store | Euclidean distance | Network distance | Travel time |
|---|---|---|---|
| Store A | 1.8 km | 3.0 km | 10 min |
| Store B | 2.2 km | 2.4 km | 6 min |
If the model uses Euclidean distance, Store A looks more attractive. If the model uses network distance or travel time, Store B looks better connected.
The “best” store therefore depends partly on how accessibility is measured.
10. Optional math
If you want the more formal version, a road network can be written as a graph:
where:
- is the set of nodes, such as junctions
- is the set of edges, such as road segments Each edge has a weight.
- If the weight is metres, we calculate network distance.
- If the weight is minutes, we calculate travel time. The shortest-path problem can then be written as:
This simply means: among all possible valid routes from origin to destination , choose the one with the lowest total cost.