get_shortest_paths based on vertex

I’m trying to use function get_shortest_path to get the shortest path from one node to another. However, some error raised. I can’t understand what’s means.
That my code:
“shortest_path = node1.get_shortest_paths(node2)”
The error messages were following:
“RuntimeWarning: Couldn’t reach some vertices at src/paths/unweight”

It means that there is no path from node1 to node2. Your graph is not (strongly) connected.

Thanks for your answers. But I want to know what’ different between the raising that Error and returning an empty list.

Note that it is not an error, it is a warning.

If you request the path in terms of edge IDs (see output argument), then the path from a vertex to itself is also represented as an empty list. This is the only case I can think of when an empty list would be returned, even though the target vertex is reachable from the source vertex.

1 Like