Find Shortest Paths in Road Networks with pgRouting
1. FOSS4G2007
Presentation
Shortest path search in real
road networks with
pgRouting
pgRouting Anton Patrushev (Orkney, Inc.)
Shortest path search in real road networks
with pgRouting 1
3. How it works
Pl/PgSQL SQL query
C++ core C wrapper
function (data)
Shortest path search in real road networks
with pgRouting 3
4. Shortest path algorithms
●
Dijkstra
●
Well known and fair shortest path algorithm
●
Always finds mathematically shortest path
●
Good for sparse networks
●
A*
●
Well known heuristic shortest path algorithm
●
Needs vertex geometry information
●
Searches through less number of vertexes
●
Good for dense networks
●
Shooting*
Shortest path search in real road networks
with pgRouting 4
6. Comparison with other
algorithms
Dijkstra cost=cost(vertex1, vertex2)
Each vertex can be visited only once
A* cost=cost(vertex1, vertex2)+H(vertex1, vertex2)
Each vertex can be visited only once
Shooting* cost=cost(edge1)+cost(edge1, edge2)+H(edge1)
Each edge can be visited only once
Parallel edges handling
Dijkstra/A* Shooting*
Shortest path search in real road networks
with pgRouting 6
7. Real road networks
A B C
A)Signs (restrict maneuvers)
B)Traffic lights (delays)
C)Road marking (restrict maneuvers)
Shortest path search in real road networks
with pgRouting 7
8. Network representation
d d c
f
d
a b c a b c
cost(eb,ab)=1min a b
cost(eb,bd)=1min
cost(eb,bc)=∞ cost(eb,bc)=1min cost(ab,bd,df)=∞
e e ... e
B ...
A C
...
A)Right turn costs too much
B)Driving through vertex b passage costs extra
C)Driving from a to f costs too much
Shortest path search in real road networks
with pgRouting 8
9. Routing data structure
Dijkstra
A*
Shooting*
Edge Edge Edge
●
id
●
id ●
id
●
cost
●
cost ●
cost
●
reverse_cost
●
reverse_cost ●
reverse_cost
●
Source vertex
●
Source vertex ●
Adjacent edge
●
id
●
id ●
rule
●
Target vertex
●
x ●
to_cost
●
id
●
y ●
Source vertex
●
Target vertex ●
id
●
id ●
x
●
x ●
y
●
y ●
Target vertex
●
id
●
x
●
y
Shortest path search in real road networks
with pgRouting 9
10. Thank you!
pgrouting.postlbs.org
orkney.co.jp
pgRouting
Shortest path search in real road networks
with pgRouting 10