implemented dijkstra's shortest path algorithm