Trait daggy::walker::Walker [] [src]

pub trait Walker<G> {
    type Index: IndexType;
    fn next(&mut self, graph: &G) -> Option<IndexPair<Self::Index>>;

    fn next_edge(&mut self, graph: &G) -> Option<EdgeIndex<Self::Index>> { ... }
    fn next_node(&mut self, graph: &G) -> Option<NodeIndex<Self::Index>> { ... }
    fn count(self, graph: &G) -> usize where Self: Sized { ... }
    fn last(self, graph: &G) -> Option<IndexPair<Self::Index>> where Self: Sized { ... }
    fn last_edge(self, graph: &G) -> Option<EdgeIndex<Self::Index>> where Self: Sized { ... }
    fn last_node(self, graph: &G) -> Option<NodeIndex<Self::Index>> where Self: Sized { ... }
    fn nth(self, graph: &G, n: usize) -> Option<IndexPair<Self::Index>> where Self: Sized { ... }
    fn nth_edge(self, graph: &G, n: usize) -> Option<EdgeIndex<Self::Index>> where Self: Sized { ... }
    fn nth_node(self, graph: &G, n: usize) -> Option<NodeIndex<Self::Index>> where Self: Sized { ... }
    fn chain<O>(self, other: O) -> Chain<G, Self::Index, Self, O> where Self: Sized, O: Walker<G, Index=Self::Index> { ... }
    fn filter<P>(self, predicate: P) -> Filter<Self, P> where Self: Sized, P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool { ... }
    fn peekable(self) -> Peekable<G, Self::Index, Self> where Self: Sized { ... }
    fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where Self: Sized, P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool { ... }
    fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where Self: Sized, P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool { ... }
    fn skip(self, n: usize) -> Skip<G, Self::Index, Self> where Self: Sized { ... }
    fn take(self, n: usize) -> Take<G, Self::Index, Self> where Self: Sized { ... }
    fn all<P>(&mut self, graph: &G, predicate: P) -> bool where P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool { ... }
    fn any<P>(&mut self, graph: &G, predicate: P) -> bool where P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool { ... }
    fn find<P>(&mut self, graph: &G, predicate: P) -> Option<IndexPair<Self::Index>> where P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool { ... }
    fn find_edge<P>(&mut self, graph: &G, predicate: P) -> Option<EdgeIndex<Self::Index>> where P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool { ... }
    fn find_node<P>(&mut self, graph: &G, predicate: P) -> Option<NodeIndex<Self::Index>> where P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool { ... }
    fn cycle(self) -> Cycle<G, Self::Index, Self> where Self: Clone + Sized { ... }
    fn fold<B, F>(self, init: B, graph: &G, f: F) -> B where Self: Sized, F: FnMut(B, &G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> B { ... }
    fn inspect<F>(self, f: F) -> Inspect<Self, F> where Self: Sized, F: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) { ... }
    fn iter(self, graph: &G) -> Iter<G, Self::Index, Self> where Self: Sized { ... }
    fn iter_weights(self, graph: &G) -> IterWeights<G, Self::Index, Self> where Self: Sized { ... }
}

A trait providing a variety of useful methods for traversing some graph type G.

Walker can be likened to the std Iterator trait. It's methods behave similarly, but it is different in that it takes a reference to some graph as an argument to its "next" method.

Walker method return types (besides the iterators) never borrow the graph. This means that we can still safely mutably borrow from the graph whilst we traverse it.

Associated Types

The unsigned integer type used for node and edge indices.

Required Methods

Fetch the EdgeIndex and NodeIndex to the next neighbour in our walk through the given Graph.

Provided Methods

The next edge in our walk for the given Graph.

The next node in our walk for the given Graph.

Counts all the steps in the entire walk of the given graph.

Walks the whole walk until reaching and returning the last edge node pair.

Walks the whole walk until reaching and returning the last edge.

Walks the whole walk until reaching and returning the last node.

Walks "n" number of steps and produces the resulting edge node pair.

Walks "n" number of steps and produces the resulting edge.

Walks "n" number of steps and produces the resulting node.

Produces a walker that will walk the entirey of self before walking the entirey of other.

Creates a walker that applies the predicate to each element returned by this walker. The only elements that will be yielded are those that make the predicate evaluate to true.

Creates a walker that has a .peek(&graph) method that returns an optional next neighbor.

Creates a walker that invokes the predicate on elements until it returns false. Once the predicate returns false, that element and all further elements are yielded.

Creates a walker that yields elements so long as the predicate returns true. After the predicate returns false for the first time, no further elements will be yielded.

Creates a walker that skips the first n steps of this walk, and then yields all further steps.

Creates a walker that yields the first n steps of this walk.

Tests whether the predicate holds true for all steps in the walk.

Tests whether any step in the walk satisfies the given predicate.

Does not step the walker past the first found step.

Returns the first edge node index pair satisfying the specified predicate.

Does not consume the walker past the first found step.

Returns the edge index satisfying the specified predicate.

Does not consume the walker past the first found step.

Returns the node index satisfying the specified predicate.

Does not consume the walker past the first found step.

Repeats the walker endlessly.

Performs a fold operation over the entire walker, returning the eventual state at the end of the walk.

This operation is sometimes called 'reduce' or 'inject'.

Creates a walker that calls a function with a reference to each index pair before yielding them. This is often useful for debugging a walker pipeline.

Converts the walker into an iterator yielding index pairs.

The returned iterator borrows the graph.

Converts the walker into an iterator yielding (&e, &n), where e is the edge weight for the next EdgeIndex and n is the node weight for the next NodeIndex.

The returned iterator borrows the graph.

Implementors