graph_cycles

Trait Cycles

Source
pub trait Cycles {
    type NodeId;

    // Required methods
    fn visit_cycles<F, B>(&self, visitor: F) -> Option<B>
       where F: FnMut(&Self, &[Self::NodeId]) -> ControlFlow<B>;
    fn cycles(&self) -> Vec<Vec<Self::NodeId>>;

    // Provided method
    fn visit_all_cycles<F>(&self, visitor: F)
       where F: FnMut(&Self, &[Self::NodeId]) { ... }
}
Expand description

Trait for identifying cycles in a graph The node identifier of the underlying graph

Required Associated Types§

Required Methods§

Source

fn visit_cycles<F, B>(&self, visitor: F) -> Option<B>
where F: FnMut(&Self, &[Self::NodeId]) -> ControlFlow<B>,

Apply the visitor to each cycle until we are told to stop

The first argument passed to the visitor is a reference to the graph and the second one a slice with all nodes that form the cycle. If at any point the visitor returns ControlFlow::Break(b) this function stops visiting any further cycles and returns Some(b). Otherwise the return value is None.

Source

fn cycles(&self) -> Vec<Vec<Self::NodeId>>

Find all cycles

Each element of the returned Vec is a Vec of all nodes in one cycle.

Provided Methods§

Source

fn visit_all_cycles<F>(&self, visitor: F)
where F: FnMut(&Self, &[Self::NodeId]),

Apply the visitor to each cycle until we are told to stop

The first argument passed to the visitor is a reference to the graph and the second one a slice with all nodes that form the cycle.

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<N, E, Ty: EdgeType, Ix: IndexType> Cycles for Graph<N, E, Ty, Ix>

Source§

type NodeId = <Graph<N, E, Ty, Ix> as GraphBase>::NodeId

Source§

fn visit_cycles<F, B>(&self, visitor: F) -> Option<B>
where F: FnMut(&Graph<N, E, Ty, Ix>, &[Self::NodeId]) -> ControlFlow<B>,

Source§

fn cycles(&self) -> Vec<Vec<Self::NodeId>>

Implementors§