Dijkstra's shortest-path algorithm.