implementing dijkstra's shortest path algorithm