[postgis-users] best finding all paths with recursive query

Shaozhong SHI shishaozhong at gmail.com
Mon Jul 17 12:24:05 PDT 2023


How about finding out all possible route paths.?
Regards, david

On Monday, 17 July 2023, Imre Samu <pella.samu at gmail.com> wrote:

> > Which one is the best example for finding all paths with recursive query?
>
> What type of graph are you working with?
>
> 1.)
> You can check Yugabyte (PostgreSQL compatible) documentation for pure SQL
> recursive-graph solutions for :
> - Undirected cyclic graph
> - Directed cyclic graph
> - Directed acyclic graph
> - Rooted tree
> - Unique containing paths
> https://docs.yugabyte.com/preview/api/ysql/the-sql-language/with-clause/
> traversing-general-graphs/common-code/
> I think there's a pretty good summary for solving basic graph problems
> with SQL, which could potentially help you understand your problem as well
> and find a solution for it...
>
> 2.)
> Or use pgr_KSP - if you're only interested in the final result and you're
> not attached to the purely recursive SQL solution.
> And it's much more optimal for large graphs as well.
> Here, you just need to provide a large enough K value (e.g., ~ maximum
> (integer/bigint) value) and then you get all possible paths.
> Or if you're only interested in the top 2, then set K=2.
>
> https://docs.pgrouting.org/latest/en/pgr_KSP.html
> "The K shortest path routing algorithm based on Yen’s algorithm*. “K” is
> the number of shortest paths desired.*"
> https://en.wikipedia.org/wiki/K_shortest_path_routing
>
> regards,
>  Imre
>
> Shaozhong SHI <shishaozhong at gmail.com> ezt írta (időpont: 2023. júl. 17.,
> H, 9:01):
>
>> Which one is the best example for finding all paths with recursive query?
>>
>> Regards,
>>
>> David
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/postgis-users
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20230717/f3b30812/attachment.htm>


More information about the postgis-users mailing list