Fixed a bug in Dijkstra algorithm.