如何在单个查询中找出到多个目标的最短路径 [英] How to find out the shortest path to many target in single query

查看:93
本文介绍了如何在单个查询中找出到多个目标的最短路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到单个查询中许多目标的最短路径。

我写了下面的代码,但是没有得到结果....请给出一个解决方案。



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.

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;

推荐答案

我推荐这个资源:

T-SQL中的图形算法

在这里,您将找到实现Dijkstra算法的存储过程,解决从加权图中的一个节点到所有其他节点的最短路径。我希望你觉得这很有用。
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.


这篇关于如何在单个查询中找出到多个目标的最短路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆