Algorithm for the shortest path problem in graph.