Skip to main content

dominator_tree

Function dominator_tree 

Source
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 satisfy root < graph.vcount().
  • modeOut for the classical control-flow dominator tree, In for the post-dominator tree (every edge reversed).

§Errors

§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);