5

How can we use use Dijkstra's algorithm to find shortest path when there are multiple edges having different weights to go from one node to another and also the availability of edges to go from one mode to another depends on the edge you have taken to come to that path.

This is the situation in the case of trip planning for cheapest path when there are multiple trains/flights between any two stations and arrival time at any intermediate node should be atleast some hours before the departure time of next flight/train.

Nikolay Kostov
  • 16,433
  • 23
  • 85
  • 123

1 Answers1

1

This problem is discussed in The Algorithm Design Manuel, chapter 4.4 - War Story: Give me a Ticket on an Airplane.

You can find it here: http://sist.sysu.edu.cn/~isslxm/DSA/textbook/Skiena.-.TheAlgorithmDesignManual.pdf (page 118)

Neithrik
  • 2,002
  • 2
  • 20
  • 33
  • 1
    No,it is not that simple.There can be a situation in which choosing cheapest path for 1st to 2nd node will compel you to choose very expensive path from 2nd to 3rd node which is clearly not the cheapest path to go from 1st to 3rd node. – Rishabh Agrawal Apr 19 '15 at 11:47
  • 1
    In the manual , it is discussed for only two nodes. But if there are n nodes, then each iteration is a nth order vector space and there can be up to n^n such vectors. Also, there can be different sets of intermediate nodes between any two destination. – Rishabh Agrawal Apr 19 '15 at 12:37
  • It is computationally hard problem indeed. – Neithrik Apr 19 '15 at 12:45