[][src]Struct gamma::traversal::DepthFirst

pub struct DepthFirst<'a, G> { /* fields omitted */ }

Implements a depth-first traversal as a Step Iterator.

use std::convert::TryFrom;
 
use gamma::graph::{ Graph, Error, DefaultGraph };
use gamma::traversal::{ DepthFirst, Step };
 
fn main() -> Result<(), Error> {
    let graph = DefaultGraph::try_from(vec![
        vec![ 1, 3 ],
        vec![ 0, 2 ],
        vec![ 1, 3 ],
        vec![ 2, 0 ]
    ])?;
    let traversal = DepthFirst::new(&graph, 0)?;
 
    assert_eq!(traversal.collect::<Vec<_>>(), vec![
        Step::new(0, 1, false),
        Step::new(1, 2, false),
        Step::new(2, 3, false),
        Step::new(3, 0, true)
    ]);
 
    Ok(())
}

Iterates edges of graph in depth-first order. To perform a depth-first search, use the depth_first function instead.

Implementations

impl<'a, G: Graph> DepthFirst<'a, G>[src]

pub fn new(graph: &'a G, root: usize) -> Result<Self, Error>[src]

pub fn into_table(self) -> (Vec<usize>, Vec<(usize, usize)>)[src]

Trait Implementations

impl<'a, G: Debug> Debug for DepthFirst<'a, G>[src]

impl<'a, G> Iterator for DepthFirst<'a, G> where
    G: Graph
[src]

type Item = Step

The type of the elements being iterated over.

impl<'a, G: PartialEq> PartialEq<DepthFirst<'a, G>> for DepthFirst<'a, G>[src]

impl<'a, G> StructuralPartialEq for DepthFirst<'a, G>[src]

impl<'a, G: Graph> TryFrom<DepthFirst<'a, G>> for DefaultGraph[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

impl<'a, G> RefUnwindSafe for DepthFirst<'a, G> where
    G: RefUnwindSafe
[src]

impl<'a, G> Send for DepthFirst<'a, G> where
    G: Sync
[src]

impl<'a, G> Sync for DepthFirst<'a, G> where
    G: Sync
[src]

impl<'a, G> Unpin for DepthFirst<'a, G>[src]

impl<'a, G> UnwindSafe for DepthFirst<'a, G> where
    G: RefUnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.