An optimal working dijkstra.