shortest path problem in weighted graph