How to get all paths between the source and destination nodes in PostGIS using PGRouting extension?

I tried the functions:

  • pgr_edgeDisjointPaths: It returns only the Disjoint paths.([40,41,42,45],[40,39,43,47,46,45])
  • pgr_bdDijkstra: It returns only the shortest path. ([40,41,42,45])

Is there any other function available to accomplish the desired result.

I want all the paths between the nodes 40 and 45 such as ([40,41,42,45],[40,39,43,47,46,45],[40,39,43,42,45] and so on), from the network mentioned in the screenshot below.


  • In your example there is an infinite number of possible paths because your system has a loop. 40,[41,42,43,39,40]*, 41,42,45
    – til_b
    Oct 12, 2022 at 8:07

1 Answer 1


I think you can get it with this function: pgr_KSP.

It gets you the K shortest paths. If you put a really high number, it should gets you all the possible path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.