[−][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; use gamma::graph::HashGraph; use gamma::traversal::depth_first; let graph = HashGraph::build(vec![ 0, 1, 2 ], vec![ (&0, &1, ()), (&1, &2, ()), (&2, &0, ()), ]).unwrap(); let traversal = depth_first(&graph, &0).unwrap(); assert_eq!(traversal.collect::<Vec<_>>(), vec![ (&0, &1, false), (&1, &2, false), (&2, &0, true) ]);