pub struct SimpleCycleIter { /* private fields */ }
Expand description
An iterator of simple cycles in a graph
SimpleCycleIter
does not itself borrow the graph, and because of this
you can run the algorithm while retaining mutable access to it, if you
use like it the following example:
use rustworkx_core::petgraph::prelude::*;
use rustworkx_core::connectivity::johnson_simple_cycles;
let mut graph = DiGraph::<_,()>::new();
let a = graph.add_node(0);
let mut cycle_iter = johnson_simple_cycles(&graph, None);
while let Some(cycle) = cycle_iter.next(&graph) {
// We can access `graph` mutably here still
graph[a] += 1;
}
assert_eq!(graph[a], 0);
Implementations§
Source§impl SimpleCycleIter
impl SimpleCycleIter
Sourcepub fn next<G>(&mut self, graph: G) -> Option<Vec<NodeIndex>>where
G: IntoEdgeReferences + IntoNodeReferences + GraphBase + EdgeCount + NodeCount + NodeIndexable,
<G as GraphBase>::NodeId: Hash + Eq,
pub fn next<G>(&mut self, graph: G) -> Option<Vec<NodeIndex>>where
G: IntoEdgeReferences + IntoNodeReferences + GraphBase + EdgeCount + NodeCount + NodeIndexable,
<G as GraphBase>::NodeId: Hash + Eq,
Return the next cycle found, if None
is returned the algorithm is complete and all
cycles have been found.
Auto Trait Implementations§
impl Freeze for SimpleCycleIter
impl RefUnwindSafe for SimpleCycleIter
impl Send for SimpleCycleIter
impl Sync for SimpleCycleIter
impl Unpin for SimpleCycleIter
impl UnwindSafe for SimpleCycleIter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more