pub struct DfsControl<'a> { /* private fields */ }Expand description
What a hook may ask or do during a run of a depth-first search: read the graph, ask whether a node
is visited or on the current path, and stop the run - the protected members of Java’s
DfsTraverser and DfsEdgeTraverser, which share this type.
Implementations§
Source§impl<'a> DfsControl<'a>
impl<'a> DfsControl<'a>
Sourcepub fn graph(&self) -> &Graph
pub fn graph(&self) -> &Graph
Returns the graph that the search runs on - Java’s protected field graph.
Time: O(1).
Sourcepub fn is_visited(&self, node: u32) -> bool
pub fn is_visited(&self, node: u32) -> bool
Returns whether the search has reached node, in this run or in an earlier one. It returns true
if enter_node has been called for node.
node is a node ID in 0..node_count; for any other value the method returns false or panics
with an index out of bounds message.
Time: O(1).
Sourcepub fn is_on_stack(&self, node: u32) -> bool
pub fn is_on_stack(&self, node: u32) -> bool
Returns whether node is on the stack of the search, that is, on the current path.
The current path leads from the node where the search started to the node being searched. A node is
on the path from its enter_node until its
leave_node. An edge from the node being searched to a node on the path
closes a cycle.
node is a node ID in 0..node_count; for any other value the method returns false or panics
with an index out of bounds message.
Time: O(1).
Sourcepub fn stop(&mut self)
pub fn stop(&mut self)
Stops the run in progress: the run returns as soon as the hook that calls this method returns, without calling another hook.
It works from every hook; from visit_edge, it does the same as
returning EdgeAction::Stop. leave_node is
not called for the nodes on the current path, but they count as visited and as no longer on the
path. This includes a node whose enter_node called this method. A later run skips every node
visited so far; it does not go on where the stopped run ended. To cancel a run from another thread,
let a hook check a flag of your own and call this method.
Time: O(1).