[Help] Graph — Shortest path — gas stations (price of fuel varies)

Revision en2, by a_r_d, 2020-10-31 19:51:55

Given a weighted undirected graph. There are N cities connected by M roads. For each road, you know the fuel needed to travel that road. A small subset of cities have gas station. The price per litre at each gas station is different. The task is to travel from city A to city B in a car with fuel capacity C minimizing the total cost.

Stuck at — Create a new graph including only the cities with gas stations along with source and destination cities. The edge weights in this graph can be found by multiple runs of Dijkstra's algorithm. Now, how to proceed with different fuel price at each node? Some DP?

Tags #shortest_path, #dynamic programing, #graph


  Rev. Lang. By When Δ Comment
en2 English a_r_d 2020-10-31 19:51:55 14
en1 English a_r_d 2020-10-31 19:48:48 685 Initial revision (published)