Inverse shortest path algorithm for weighted graphs