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
[Generic] 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
. Ifspace
is notNone
, it is used instead of creating a new workspace for graph traversal.
§Returns
true
: if there exists a path starting atfrom
and reachingto
orfrom
andto
are equal.false
: otherwise.
§Complexity
- Time complexity: O(|V| + |E|).
- Auxiliary space: O(|V|) or O(1) if
space
was provided.
where |V| is the number of nodes and |E| is the number of edges.