[pgrouting-users] Strange results using pgr_kdijkstraCost

Hi all,

I’m using osm data to calculate time distances from one source node to multiple destinations. For this I’m using pgr_kdijkstraCost. Because I found a few results strange, I used pgr_dijkstra (and pgr_astar) to test total distances between a few nodes.

Given one source and one destination, I used this code to calculate total cost between two nodes

select sum(cost) from
(SELECT seq, id1 AS node, id2 AS edge, cost FROM pgr_dijkstra(’
SELECT gid AS id,
length::double precision AS cost
FROM ways’,
97972,342392, false, false)) as foo;

*column “custo” was calculated using: custo = (60 * length) / (maxspeed_forward)

The result for test1 is 115 minutes.

Using pgr_kdijkstraCost with only one target (node 342392), the code is:

SELECT seq, id1 AS source, id2 AS target, cost FROM pgr_kdijkstraCost($$
SELECT gid AS id,
custo::double precision AS cost
FROM ways, classes c
WHERE class_id = c.id
97972, array[342392], false, false);

The result of test2 is 66388 minutes!

Using the same code with over 2 thousand targets, it runs smoothly, with a few strange results - as this one.

Perhaps there’s something obvious I’m missing.

Thanks in advance for any help.