[pgrouting-dev] Dijkstra's solution - How to get tree?

Stephen Woodbridge woodbri at swoodbridge.com
Wed May 5 00:58:21 EDT 2010


Anton Patrushev wrote:
> Hi Steve,
> 
> Can Driving Distance function give you some hints? It is nothing more
> than Dijkstra where a distance (not a target vertex) is a quit
> condition. It returns only vertices, but with some hacking you can
> make it return a tree. I think.
> 
> Cheers,
> Anton.

Thanks Anton,

I will look at that tomorrow when its not so late.

I am thinking it would be nice with we could do something like:

select node_id, cost, parent_id
   from dijkstra(start_node_id, max_distance, ....);

or something like that. From these tuples you can easily construct the 
tree extract the route from to all or any nodes in the tree, etc.

You can also find all terminal nodes because they will not be 
represented in the parent_id column, like:

select node_id from treetable
except
select parent_id as node_id from treetable;


-Steve


More information about the pgrouting-dev mailing list