Finding the shortest path with Dijkstra