Implementing dijkstra shortest path algorithm