Solution for ids problem in Dijkstra algorithm.