pgRouting Manual (2.3)

pgr_apspWarshall - Deprecated Function

«  pgr_apspJohnson - Deprecated function   ::   Contents   ::   pgr_kDijkstra - Deprecated Functions  »

pgr_apspWarshall - Deprecated Function


This function is deprecated!!!

  • It has been replaced by a new function, is no longer supported, and may be removed from future versions.
  • All code that uses this function should be converted to use its replacement: pgr_floydWarshall.


pgr_apspWarshall - Returns all costs for each pair of nodes in the graph.


The Floyd-Warshall algorithm (also known as Floyd’s algorithm and other names) is a graph analysis algorithm for finding the shortest paths between all pairs of nodes in a weighted graph. Returns a set of pgr_costResult (seq, id1, id2, cost) rows for every pair of nodes in the graph.

pgr_costResult[] pgr_apspWarshall(sql text, directed boolean, reverse_cost boolean);



a SQL query that should return the edges for the graph that will be analyzed:

SELECT id, source, target, cost FROM edge_table;
id:int4 identifier of the edge
source:int4 identifier of the source vertex for this edge
target:int4 identifier of the target vertex for this edge
cost:float8 a positive value for the cost to traverse this edge
reverse_cost:float8 (optional) a positive value for the reverse cost to traverse this edge

true if the graph is directed


if true, the reverse_cost column of the SQL generated set of rows will be used for the cost of the traversal of the edge in the opposite direction.

Returns set of pgr_costResult[]:

seq:row sequence
id1:source node ID
id2:target node ID
cost:cost to traverse from id1 to id2


  • Deprecated in version 2.0.0
  • New in version 2.0.0


SELECT * FROM pgr_apspWarshall(
        'SELECT id::INTEGER, source::INTEGER, target::INTEGER, cost FROM edge_table WHERE id < 5',
        false, false
NOTICE:  Deprecated function: Use pgr_floydWarshall instead
 seq | id1 | id2 | cost 
   0 |   1 |   2 |    1
   1 |   1 |   5 |    2
   2 |   2 |   1 |    1
   3 |   2 |   5 |    1
   4 |   5 |   1 |    2
   5 |   5 |   2 |    1
(6 rows)

The query uses the Sample Data network.

«  pgr_apspJohnson - Deprecated function   ::   Contents   ::   pgr_kDijkstra - Deprecated Functions  »