Dijkstra's algorithm.