Corrected the basic idea for dijkstra.