The behaviour on matching booleans is trivial and well understood (Refer to answer provided by MappaGnosis). But non-matching booleans are not irrelevant and the corresponding behaviour justifies the need of these two arguments. I would try to state the behaviour with non-matching booleans with examples.
- False, True Ignores directed graph settings but distinguishes edges of the corresponding graph according to the direction in which it is travelled. Shown below are two example queries and outputs on a single segment path. Both queries are exactly similar except for the parameter settings. First one corresponds to False, False settings and the latter one corresponds to False, True settings:
Query-1
select seq, id1 as node, id2 as edge, cost FROM pgr_dijkstra('SELECT gid AS id, source::integer, target::integer, length::double precision AS cost, length::double precision/2 AS reverse_cost FROM links_topology', (select source from links_topology where gid=199591), (select target from links_topology where gid=200466), false, false) as A;
Output:
seq | node | edge | cost | -----+--------+--------+------------- 0 | 165702 | 199931 | 66.04336762 | 1 | 165969 | -1 | 0 |
Query-2
select seq, id1 as node, id2 as edge, cost FROM pgr_dijkstra('SELECT gid AS id, source::integer, target::integer, length::double precision AS cost, length::double precision/2 AS reverse_cost FROM links_topology', (select source from links_topology where gid=199591), (select target from links_topology where gid=200466), false, true) as A;
Output:
seq | node | edge | cost | -----+--------+--------+------------- 0 | 165702 | 199931 | 33.02168381 | 1 | 165969 | -1 | 0 |
The path segment in the route was from target node to source node of edge 199931. Choosing (False, False) settings ignored the reverse cost but (False, True) chose the reverse cost for computing shortest path.
- True, False Expects a directed graph but ignores reverse costs if provided which anyways wouldn't make sense because in a directed graph, edges can't be travelled in opposite direction.
Having understood the behaviour, one may ask:
How can (False, True) be used in a real world application?
There are two uses I can think of:
a) Reliably updating a map on temporary basis: can be done without making changes to the existing map to convert a two-way lane to one-way (make the reverse cost 0 for the required edges which are stored in a seperate table with which a join should be computed to get the reverse costs).
b) Fetching ETA: a 2-WAY road would have different time cost according to the speed differences in the opposite directions. Using a directed graph could be a solution, but then the graph size needs to be doubled which would have performance overheads on route computations and other graph based queries.