pub fn dominator_tree(
graph: &Graph,
root: VertexId,
mode: DominatorMode,
) -> IgraphResult<DominatorTree>Expand description
Compute the Lengauer-Tarjan dominator tree of a directed flowgraph.
See DominatorTree for the result shape and DominatorMode for
the direction selector.
§Arguments
graph— directed input graph. Undirected graphs are rejected.root— root vertex id; must satisfyroot < graph.vcount().mode—Outfor the classical control-flow dominator tree,Infor the post-dominator tree (every edge reversed).
§Errors
IgraphError::InvalidArgumentwhengraphis undirected or whengraph.vcount()exceedsi32::MAX(which would make the internal DFS-order index overflow).IgraphError::VertexOutOfRangewhenrootis not a valid vertex id.
§Examples
use rust_igraph::{Graph, dominator_tree, DominatorMode};
// 0 → 1: the root dominates every other reachable vertex trivially.
let mut g = Graph::new(2, true).unwrap();
g.add_edge(0, 1).unwrap();
let dt = dominator_tree(&g, 0, DominatorMode::Out).unwrap();
assert_eq!(dt.idom, vec![-1, 0]);
assert_eq!(dt.leftout, Vec::<u32>::new());
assert_eq!(dt.tree.ecount(), 1);