pgRouting is equipped with quite a few algorithms specialized in different aspects of routing. Although all are routing algorithms, for the sake of convenience, let's split them into the following artificial functional groups:
- All pairs shortest path
- Shortest Path
- Driving distance
- Traveling Sales Person
All pairs shortest path algorithms are good for calculating the total costs of the shortest path for each node in the graph. There are two of those available in pgRouting:
- All pairs shortest path, Johnson's algorithm: Good for calculating costs over sparse graphs
- All pairs shortest path, Floyd-Warshall algorithm: Good for calculating costs over dense graphs
Let's give it a shot:
select * from pgr_floydWarshall('select gid as id, the_geom, source::int4, target::int4, cost::float from pgr.ways where ST_Intersects(the_geom, ST_MakeEnvelope(16.3618,48.2035,16.3763,48.2112,4326))', false);
This query picks roughly a thousand of the edges of Vienna city center...