implementation and extension of the Dijkstra’s algorithm