How can we use Dijkstra’s or Bellman–Ford’s algorithm to find shortest path in a graph whose some of edges are affected if we go specific vertices. Such that, the affected edge’s length will be more than or less than the original length.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If I understand this right, you want to change the cost of an edge in a graph depending on nodes which are visited in your current path. An example from the comments is:
“Edge AB has length 3, but if you also visit node C, AB’s length will be 5”
Now, there doesn’t seem to be a way for something like Djikstra’s algorithm to be used as there is a greedy step in that algorithm which picks the ‘best’ node at every stage. The notion that the ‘best’ node at that point may change at a later time (due to a rule such as above) violates the concept of the greedy approach which assumes that we are effectively visiting nodes in order from best to worst cost. I’m not certain if this is NP hard as suggested but it certainly cannot use a Dijikstra kind of approach from the start. +1 for the problem though.