pub fn dfs(graph: &Graph, root: VertexId) -> IgraphResult<Vec<VertexId>>Expand description
Pre-order visit of vertices reachable from root, in DFS order.
Vertices unreachable from root are not included. Errors if root
is not a valid vertex. Neighbour iteration follows
Graph::neighbors’s order, which matches python-igraph’s
Graph.dfs and the upstream igraph_dfs order.
§Examples
use rust_igraph::{Graph, dfs};
// 0 - 1 - 3
// |
// 2
let mut g = Graph::with_vertices(4);
g.add_edge(0, 1).unwrap();
g.add_edge(0, 2).unwrap();
g.add_edge(1, 3).unwrap();
let order = dfs(&g, 0).unwrap();
assert_eq!(order[0], 0); // always start at root
assert_eq!(order.len(), 4); // visits whole component