I want to find the cheapest path between 2 vertices and I can choose one path which I can go for free., e.g:
Cheapest path between vertices 1 and 6 is 1-3-4-5-6 - I go on edge 1-3 (cost 30) for free and it gives me total cost 21.
Is there any other way than checking all paths one by one?
One way to do it would be to do the following:
Basically what happens is that you switch from subgraph G to G' when you use your joker.
You can generalise from there to any number of joker edges by adding extra copies and linking each new one to the last. In that case however you may have to add targets using less jokers in order to account for the cases where the shortest path requires less edges than you have jokers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With