[pgrouting-users] Wrong edge

I've tried to make this example of how the wrong edge is chosen, as
simple as possible:

drop table if exists edge;
  id int4,
  source int4,
  target int4,
  cost float8,
  reverse_cost float8);

truncate edge;
insert into edge values ( 2, 1, 2, 2, 2);
insert into edge values ( 1, 1, 2, 1, 1);

SELECT * FROM shortest_path('SELECT * from edge', 1, 2, true, true);

# Choses the longer route:

vertex_id | edge_id | cost
         1 | 2 | 2
         2 | -1 | 0
(2 rows)

If I change the order of the inserts it gets the right answer.

I think this bug is related to



Hi Simon,

That is a known issue with Dijkstra/A* (and any vertex-to-vertex) algorithms.
Both your edges have same source and target vertices, which means that
for such algorithms (which care only about vertices and have no such
entity as an edge) only one of them exists. You can break one edge to
two or use edge-to-edge algorithm, such as Shooting*.