the shortest route algorithm for Dijkstra