[−][src]Function gamma::traversal::depth_first
pub fn depth_first<'a, N, G>(
graph: &'a G,
root: &'a N
) -> Result<DepthFirst<'a, N, G>, Error> where
G: Graph<'a, N>,
N: 'a + Hash + Eq,
Implements a depth-first traversal as an edge Iterator. Reports cycle closure edges.
use gamma::graph::{ Graph, IndexGraph, Error }; use gamma::traversal::depth_first; fn main() -> Result<(), Error> { let graph = IndexGraph::build(vec![ vec![ 1, 2 ], vec![ 0, 2 ], vec![ 1, 0 ] ])?; let traversal = depth_first(&graph, &0)?; assert_eq!(traversal.collect::<Vec<_>>(), vec![ (&0, &1, false), (&1, &2, false), (&2, &0, true) ]); Ok(()) }