I am currently developing an application to create tours for motorbikes. At the current stage of development there is a start/endpoint and several points which outline the tour. Between these points the pgr_dijkstra function is used (with a customized cost function). The problem is best described by the picture attached.
Is there a way to avoid an edge getting traveled twice? I have tried to use the reverse cost column with a high cost but as the graph is not directed I get odd results. At least the pgrouting documentation states that the graph has to be directed to use the reverse cost if I understood that correctly.
sql := 'SELECT DISTINCT ON (seq) seq, id, the_geom, id1 AS node, id2 AS edge, cost, km FROM pgr_dijkstra('' SELECT id, source::integer, target::integer, my_cost::double precision AS cost, FROM network WHERE network.the_geom && bbox '',' || source || ',' || target || ', false, false), network WHERE id2 = network.id';
This is the statement to create a part of the route. It is nested inside a loop which passes new source and target in every iteration as long as there are some. This code is executed and returned record-wise.