pub struct TriColorDepthFirstSearch<'graph, G>where
    G: ?Sized + DirectedGraph + WithNumNodes + WithSuccessors,
{ graph: &'graph G, stack: Vec<Event<G::Node>>, visited: BitSet<G::Node>, settled: BitSet<G::Node>, }
Expand description

A depth-first search that also tracks when all successors of a node have been examined.

This is based on the DFS described in Introduction to Algorithms (1st ed.), hereby referred to as CLR. However, we use the terminology in NodeStatus above instead of “discovered”/“finished” or “white”/“grey”/“black”. Each node begins the search with no status, becomes Visited when it is first examined by the DFS and is Settled when all nodes reachable from it have been examined. This allows us to differentiate between “tree”, “back” and “forward” edges (see TriColorVisitor::node_examined).

Unlike the pseudocode in CLR, this implementation is iterative and does not use timestamps. We accomplish this by storing Events on the stack that result in a (possible) state change for each node. A Visited event signifies that we should examine this node if it has not yet been Visited or Settled. When a node is examined for the first time, we mark it as Visited and push a Settled event for it on stack followed by Visited events for all of its predecessors, scheduling them for examination. Multiple Visited events for a single node may exist on the stack simultaneously if a node has multiple predecessors, but only one Settled event will ever be created for each node. After all Visited events for a node’s successors have been popped off the stack (as well as any new events triggered by visiting those successors), we will pop off that node’s Settled event.

Fields

graph: &'graph Gstack: Vec<Event<G::Node>>visited: BitSet<G::Node>settled: BitSet<G::Node>

Implementations

Performs a depth-first search, starting from the given root.

This won’t visit nodes that are not reachable from root.

Performs a depth-first search, starting from G::start_node().

This won’t visit nodes that are not reachable from the start node.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Layout

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.