implement dijkstra algorithm for finding shortest path