Click here to Skip to main content
15,891,409 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to find out shortest path to many target in single query.
I have write the below code, but its not getting the result.... please give a solution for this.

SQL
create table test1 as
	SELECT pt.gid,
               seq,id1 AS note, 
               id2 AS edge, 
               pt.cost,
               pt.reverse_cost ,
               pt.the_geom 
       FROM pgr_kdijkstraPath(
	       'SELECT 
                     gid AS id,
                     source,
                     target,
                     st_length(the_geom) AS cost,
                     reverse_cost,
                     x1,y1,x2,y2 
               FROM 
                     road_network', 
               26, 
               array[1055,2013], true, true) as di 
        JOIN road_network pt ON di.id2 = pt.gid;
Posted
Updated 1-Oct-15 0:26am
v2
Comments
Andy Lanng 1-Oct-15 4:34am    
P!=NP
Maciej Los 1-Oct-15 4:57am    
Virtual 5!

1 solution

I recommend this resource:
Graph Algorithms in T-SQL
Here you will find a stored procedure to implement Dijkstra's algorithm, solving the shortest path from one node to all other nodes in a weighted graph. I hope you find this helpful.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900