Objective implementation od Dijkstra's algorithm.