dfs_full

Function dfs_full 

Source
pub fn dfs_full<G, F>(graph: &G, visitor: &mut F) -> Vec<NodeId>
where G: Graph, F: FnMut(NodeId),
Expand description

Runs dfs_recursive from every unvisited node, covering all connected components. Returns a single finish-order vec spanning the whole graph.

Used internally by topological sort and SCC algorithms.

ยงExamples

use graph_core::{AdjacencyList, Graph};
use graph_traversal::dfs::dfs_full;

let mut g: AdjacencyList<()> = AdjacencyList::directed();
let a = g.add_node(());
let b = g.add_node(()); // isolated

let finish = dfs_full(&g, &mut |_| {});
assert_eq!(finish.len(), 2);