FOSS4G2007 Presentation Shortest path search in real road networks with pgRouting pgRouting Anton Patrushev (Orkney, Inc.)Shortest path search in real road networkswith pgRouting 1
IntroductionpgRouting is an extension of PostgreSQL and PostGIS. A predecessor of pgRouting pgDijkstra, written by Sylvain Pasche from Camptocamp, was extended by Orkney (Japan) and renamed to pgRouting.pgRouting includes:* Shortest path search (Dijkstra, A*, Shooting*)* Traveling Salesperson Problem (TSP) solution* Driving distance polygon calculationShortest path search in real road networkswith pgRouting 2
How it works Pl/PgSQL SQL query C++ core C wrapper function (data)Shortest path search in real road networkswith pgRouting 3
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 networkswith pgRouting 4
Shooting*● Edgebased heuristic shortest path algorithm ● Supports maneuver restrictions and traffic lights● Properly processes parallel edges● Good for dense networksPredecessors:● Modified A* Wolfgang Schmid, 2000, Stephan Winter, 2002● C* Ingrid Flinsenberg, 2004Shortest path search in real road networkswith pgRouting 5
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 networkswith pgRouting 6
Real road networks A B CA)Signs (restrict maneuvers)B)Traffic lights (delays)C)Road marking (restrict maneuvers)Shortest path search in real road networkswith pgRouting 7
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 muchB)Driving through vertex b passage costs extraC)Driving from a to f costs too muchShortest path search in real road networkswith pgRouting 8
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 ● yShortest path search in real road networkswith pgRouting 9
Thank you! pgrouting.postlbs.org orkney.co.jp pgRoutingShortest path search in real road networkswith pgRouting 10
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.