Skip to main content

DfsControl

Struct DfsControl 

Source
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>

Source

pub fn graph(&self) -> &Graph

Returns the graph that the search runs on - Java’s protected field graph.

Time: O(1).

Source

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).

Source

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).

Source

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).

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for DfsControl<'a>

§

impl<'a> Freeze for DfsControl<'a>

§

impl<'a> RefUnwindSafe for DfsControl<'a>

§

impl<'a> Send for DfsControl<'a>

§

impl<'a> Sync for DfsControl<'a>

§

impl<'a> Unpin for DfsControl<'a>

§

impl<'a> UnsafeUnpin for DfsControl<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.