[Cartoweb-users] pgdijkstra error

PORTANERI Franck fportaneri.ext at rd.francetelecom.com
Fri Mar 31 09:44:29 EST 2006


Hi all,

I have a problem with the pgdijkstra contrib:
To illustrate it, let say I have 2 points 1 and 2, joined by 2 ways 
(both ways allowing both directions), one direct way of  10m, and one 
more "touristic" of about 100m.

 1 + <------- 10m -------> + 2
   ^                       ^
   |                       |
   |                       |
   +-------- 100m ----------

The test code is:

create table djtest (
  id serial NOT NULL,
  source int4,
  target int4,
  cost float8,
  reverse_cost float8
);

insert into djtest VALUES (1, 1, 2, 10, 10);
insert into djtest VALUES (2, 2, 1, 100, 100);    
select * from shortest_path('select * from djtest', 1, 2, true, true) 
limit 1;
 step | vertex_id | edge_id | cost
------+-----------+---------+------
    0 |         1 |       1 |   10
(1 row)

Good!! This is what we expect!

However,

delete from djtest;
insert into djtest VALUES (2, 2, 1, 100, 100);    
insert into djtest VALUES (1, 1, 2, 10, 10);
select * from shortest_path('select * from djtest', 1, 2, true, true) 
limit 1;

 step | vertex_id | edge_id | cost
------+-----------+---------+------
    0 |         1 |       2 |  100
(1 row)

Wrong!!!

Dependending the order of data creation in the table, the result may be 
wrong... Looks like if shortest_path() returns the first path found:

Is there a way to fix this?

Thanks
Franck



More information about the Cartoweb-users mailing list