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 from our OSM ways table and outputs something like this (the documentation mentions that the recommended usage is running the method on up to 3500 rows, as otherwise the performance will drop drastically):
start_vid| end_vid| agg_cost
-----------+---------+---------------------
58529| 68104| 0.000602242417967414
58529| 47346| 0.00909508063542836
58529| 48852| 0.00986963261560741
58529| 39868| 0.00571458698714135
58529| 40505| 0.00620416841040188
...
All pairs algorithms do not return a path; what you get is a list of total costs of the shortest paths between each node of the graph. The first row reports cost 0, as the start (id1) and end (id2) nodes are the same. Next goes the list of costs for the shortest routes to the other nodes, starting from the node in the id1 column.
Our query returns over a million combinations, so it may take a while to compute.