Skip to main content

Graph

Trait Graph 

Source
pub trait Graph<Node> {
    type NodesIter<'a>: Iterator<Item = Node>
       where Self: 'a;
    type SuccessorsIter<'a>: Iterator<Item = Node>
       where Self: 'a;

    // Required methods
    fn nodes(&self) -> Self::NodesIter<'_>;
    fn successors(&self, node: Node) -> Self::SuccessorsIter<'_>;

    // Provided methods
    fn by_ref(&self) -> &Self { ... }
    fn filter_nodes<F>(self, predicate: F) -> FilterNodes<Self, F>
       where Self: Sized,
             F: Fn(&Node) -> bool { ... }
}
Expand description

A trait for any kind of graph data structure.

Required Associated Types§

Source

type NodesIter<'a>: Iterator<Item = Node> where Self: 'a

The iterator type returned by Nodes::nodes.

Source

type SuccessorsIter<'a>: Iterator<Item = Node> where Self: 'a

The iterator type returned by Successors::successors.

Required Methods§

Source

fn nodes(&self) -> Self::NodesIter<'_>

Iterate over the nodes in this graph.

Source

fn successors(&self, node: Node) -> Self::SuccessorsIter<'_>

Iterate over the successors of the given node.

Provided Methods§

Source

fn by_ref(&self) -> &Self

Like Iterator::by_ref but for Graph.

Source

fn filter_nodes<F>(self, predicate: F) -> FilterNodes<Self, F>
where Self: Sized, F: Fn(&Node) -> bool,

Use the given predicate to filter out certain nodes from the 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.

Implementations on Foreign Types§

Source§

impl<T, Node> Graph<Node> for &T
where T: ?Sized + Graph<Node>,

Source§

type NodesIter<'a> = <T as Graph<Node>>::NodesIter<'a> where Self: 'a

Source§

type SuccessorsIter<'a> = <T as Graph<Node>>::SuccessorsIter<'a> where Self: 'a

Source§

fn nodes(&self) -> Self::NodesIter<'_>

Source§

fn successors(&self, node: Node) -> Self::SuccessorsIter<'_>

Implementors§

Source§

impl<G, F, Node> Graph<Node> for FilterNodes<G, F>
where G: Graph<Node>, F: Fn(&Node) -> bool,

Source§

type NodesIter<'a> = Filter<<G as Graph<Node>>::NodesIter<'a>, &'a F> where Self: 'a

Source§

type SuccessorsIter<'a> = Filter<<G as Graph<Node>>::SuccessorsIter<'a>, &'a F> where Self: 'a

Source§

impl<Node> Graph<Node> for EntityGraph<Node>
where Node: EntityRef,

Source§

type NodesIter<'a> = Keys<Node> where Self: 'a

Source§

type SuccessorsIter<'a> = Copied<Iter<'a, Node>> where Self: 'a