Trait VertexWalker

Source
pub trait VertexWalker<'graph>: Walker<'graph> {
    // Required method
    fn next(
        &mut self,
        graph: &'graph Self::Graph,
    ) -> Option<<Self::Graph as Graph>::VertexId>;

    // Provided methods
    fn vertices_by_id<Iter>(
        self,
        vertex_ids: Iter,
    ) -> VertexIter<'graph, Self, Iter::IntoIter>
       where Iter: IntoIterator<Item = <Self::Graph as Graph>::VertexId> { ... }
    fn vertices<'search>(
        self,
        vertex_search: VertexSearch<'search, Self::Graph>,
    ) -> Vertices<'search, 'graph, Self> { ... }
    fn filter<Predicate>(
        self,
        predicate: Predicate,
    ) -> VertexFilter<'graph, Self, Predicate>
       where Predicate: Fn(&<Self::Graph as Graph>::VertexReference<'_>, &Self::Context) -> bool { ... }
    fn control_flow<Predicate>(
        self,
        predicate: Predicate,
    ) -> VertexControlFlow<'graph, Self, Predicate>
       where Self: 'graph,
             for<'a> Predicate: Fn(&'a <Self::Graph as Graph>::VertexReference<'graph>, &mut Self::Context) -> ControlFlow<Option<&'a <Self::Graph as Graph>::VertexReference<'graph>>, Option<&'a <Self::Graph as Graph>::VertexReference<'graph>>> { ... }
    fn take(self, n: usize) -> VertexTake<'graph, Self> { ... }
    fn detour<Path, Terminal, WalkerBuilder>(
        self,
        path: Path,
    ) -> Detour<'graph, Self, Path, Terminal>
       where Path: Fn(VertexWalkerBuilder<'graph, ImmutableMarker, Self::Graph, Waypoint<'graph, Self::Graph, Self::Context>>) -> WalkerBuilder,
             WalkerBuilder: Into<WalkerBuilder<'graph, ImmutableMarker, Self::Graph, Terminal>>,
             Terminal: Walker<'graph, Graph = Self::Graph>,
             <Self as Walker<'graph>>::Graph: 'graph { ... }
    fn context<Callback, Context>(
        self,
        predicate: Callback,
    ) -> VertexContext<'graph, Self, Callback, Context>
       where Callback: Fn(&<Self::Graph as Graph>::VertexReference<'_>, &Self::Context) -> Context { ... }
    fn edges(
        self,
        search: EdgeSearch<'_, Self::Graph>,
    ) -> Edges<'_, 'graph, Self> { ... }
    fn reduce<Reducer>(
        self,
        reducer: Reducer,
    ) -> VertexReduce<'graph, Self, Reducer>
       where Reducer: for<'a> Fn(&'a <Self::Graph as Graph>::VertexReference<'graph>, &'a <Self::Graph as Graph>::VertexReference<'graph>, &Self::Context) -> &'a <Self::Graph as Graph>::VertexReference<'graph>,
             <Self as Walker<'graph>>::Graph: 'graph { ... }
}
Expand description

A trait that defines the basic behavior of a vertex walker, which is a specialized type of graph walker that focuses on traversing and exploring the vertices in a graph.

The VertexWalker trait provides a set of methods for working with vertices, such as filtering vertices based on a predicate, limiting the number of vertices returned, and collecting the vertices into a specific data structure.

Implementors of this trait are responsible for defining the specific graph representation they work with (via the Graph associated type) and the internal state they need to track during the walk (via the Context associated type).

Required Methods§

Source

fn next( &mut self, graph: &'graph Self::Graph, ) -> Option<<Self::Graph as Graph>::VertexId>

Returns the next vertex ID in the traversal.

This method advances the walker and returns the ID of the next vertex, or None if there are no more vertices to traverse.

§Parameters
  • graph: The graph being traversed
§Returns

The ID of the next vertex, or None if the traversal is complete

Provided Methods§

Source

fn vertices_by_id<Iter>( self, vertex_ids: Iter, ) -> VertexIter<'graph, Self, Iter::IntoIter>
where Iter: IntoIterator<Item = <Self::Graph as Graph>::VertexId>,

Source

fn vertices<'search>( self, vertex_search: VertexSearch<'search, Self::Graph>, ) -> Vertices<'search, 'graph, Self>

Source

fn filter<Predicate>( self, predicate: Predicate, ) -> VertexFilter<'graph, Self, Predicate>
where Predicate: Fn(&<Self::Graph as Graph>::VertexReference<'_>, &Self::Context) -> bool,

Source

fn control_flow<Predicate>( self, predicate: Predicate, ) -> VertexControlFlow<'graph, Self, Predicate>
where Self: 'graph, for<'a> Predicate: Fn(&'a <Self::Graph as Graph>::VertexReference<'graph>, &mut Self::Context) -> ControlFlow<Option<&'a <Self::Graph as Graph>::VertexReference<'graph>>, Option<&'a <Self::Graph as Graph>::VertexReference<'graph>>>,

Source

fn take(self, n: usize) -> VertexTake<'graph, Self>

Source

fn detour<Path, Terminal, WalkerBuilder>( self, path: Path, ) -> Detour<'graph, Self, Path, Terminal>
where Path: Fn(VertexWalkerBuilder<'graph, ImmutableMarker, Self::Graph, Waypoint<'graph, Self::Graph, Self::Context>>) -> WalkerBuilder, WalkerBuilder: Into<WalkerBuilder<'graph, ImmutableMarker, Self::Graph, Terminal>>, Terminal: Walker<'graph, Graph = Self::Graph>, <Self as Walker<'graph>>::Graph: 'graph,

Source

fn context<Callback, Context>( self, predicate: Callback, ) -> VertexContext<'graph, Self, Callback, Context>
where Callback: Fn(&<Self::Graph as Graph>::VertexReference<'_>, &Self::Context) -> Context,

Source

fn edges(self, search: EdgeSearch<'_, Self::Graph>) -> Edges<'_, 'graph, Self>

Source

fn reduce<Reducer>( self, reducer: Reducer, ) -> VertexReduce<'graph, Self, Reducer>
where Reducer: for<'a> Fn(&'a <Self::Graph as Graph>::VertexReference<'graph>, &'a <Self::Graph as Graph>::VertexReference<'graph>, &Self::Context) -> &'a <Self::Graph as Graph>::VertexReference<'graph>, <Self as Walker<'graph>>::Graph: 'graph,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§