Dijkstra algorithm preparation