pub fn has_path_connecting<G>(
g: G,
from: G::NodeId,
to: G::NodeId,
space: Option<&mut DfsSpace<G::NodeId, G::Map>>,
) -> boolwhere
G: IntoNeighbors + Visitable,Expand description
Check if there exists a path starting at from and reaching to.
If from and to are equal, this function returns true.
§Arguments:
g: an input graph.from: the first node of a desired path.to: the last node of a desired path.space: optionalDfsSpace. Ifspaceis notNone, it is used instead of creating a new workspace for graph traversal.
§Returns
true: if there exists a path starting atfromand reachingtoorfromandtoare equal.false: otherwise.
§Complexity
- Time complexity: O(|V| + |E|).
- Auxiliary space: O(|V|) or O(1) if
spacewas provided.
where |V| is the number of nodes and |E| is the number of edges.