Closed pnevyk closed 1 year ago
I am in favor of (2), returning an error from run
. Because when the goal is specified, the user desires to find the shortest path and its distance to that target vertex and has right to expect their availability after getting a successful result. In that case, returning None
from dist
could be confusing. Returning error early should prevent such confusion.
In general case, when no goal is specified, it is fine to return None
for unreachable vertices, because the user should keep in mind that a graph in general can contain unreachable vertices.
The shortest paths API allows to specify a goal vertex:
What should be the behavior when the target vertex is not reachable from the start vertex?
None
.run
.