[][src]Struct gamma::traversal::BreadthFirst

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

Implements a breadth-first traversal as a Step Iterator.

use std::convert::TryFrom;
use gamma::graph::{ Graph, Error, DefaultGraph };
use gamma::traversal::{ BreadthFirst, 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 = BreadthFirst::new(&graph, 0)?;
 
    assert_eq!(traversal.collect::<Vec<_>>(), vec![
        Step::new(0, 1, false),
        Step::new(0, 3, false),
        Step::new(1, 2, false),
        Step::new(3, 2, true)
    ]);
 
    Ok(())
}

#[derive(Debug,PartialEq)]

Implementations

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

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

Trait Implementations

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

type Item = Step

The type of the elements being iterated over.

Auto Trait Implementations

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

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

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

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

impl<'a, G> UnwindSafe for BreadthFirst<'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.