1

I have a table with 2 columns: column A with the startvertex and column B with endvertex.

How can I do a OD pairs shortest path?

It is with a loop I suppose, but how can this loop be implemented into pgr_Dijkstra? It's impossible do to all the OD pairs manually, so an iteration is necessary.

I have already a working query for pgr_Dijkstra for a single point-to-point, but the problem is to do it for all the OD-pairs one-by-one.

1 Answer 1

0

pgr_Dijkstra caan also solve 1->n and n->m shortest path. When you look at the function documentation you will see, that you can pass an array of start or end ID's.

SELECT * FROM pgr_dijkstra( 'SELECT id, source, target, cost, reverse_cost FROM edge_table', ARRAY[2,11], ARRAY[3,5], FALSE );

http://docs.pgrouting.org/2.4/en/pgr_dijkstra.html#pgr-dijkstra-many-to-many

1
  • 1
    This is for many×many, not pair to pair. Commented Jul 11, 2018 at 15:10

Your Answer

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

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