Fixes the implementation for Dijkstra's algorithm.