pub fn compute_dominators(
        &self,
        start_index: usize,
    ) -> Result<FxHashMap<usize, FxHashSet<usize>>> {
        if !self.vertices.contains_key(&start_index) {
            bail!("vertex {} not in graph", start_index);
        }

        let dom_tree = self.compute_dominator_tree(start_index)?;
        let dom_tree_pre_oder = dom_tree.compute_pre_order(start_index)?;

        let mut dominators: FxHashMap<usize, FxHashSet<usize>> = FxHashMap::default();

        for vertex in dom_tree_pre_oder {
            let mut doms = FxHashSet::default();
            doms.insert(vertex);
            for pred in &dom_tree.predecessors[&vertex] {
                doms.extend(&dominators[pred])
            }
            dominators.insert(vertex, doms);
        }

        Ok(dominators)
    }
/// Computes dominators for all vertices in the graph
Computes dominators for all vertices in the graph
Computes dominators for all vertices in the graph
pub fn compute_dominators(
        &self,
        start_index: usize,
    ) -> Result<FxHashMap<usize, FxHashSet<usize>>> {
        if !self.vertices.contains_key(&start_index) {
            bail!("vertex {} not in graph", start_index);
        }
        let dom_tree = self.compute_dominator_tree(start_index)?;
        let dom_tree_pre_oder = dom_tree.compute_pre_order(start_index)?;
        let mut dominators: FxHashMap<usize, FxHashSet<usize>> = FxHashMap::default();
        for vertex in dom_tree_pre_oder {
            let mut doms = FxHashSet::default();
            doms.insert(vertex);
            for pred in &dom_tree.predecessors[&vertex] {
                doms.extend(&dominators[pred])
            }
            dominators.insert(vertex, doms);
        }
        Ok(dominators)
    }
pub fn compute_dominators ( & self , start_index : usize , ) -> Result < FxHashMap < usize , FxHashSet < usize > > > { if ! self . vertices . contains_key ( & start_index ) { bail ! ( " " start_index ) ; } let dom_tree = self . compute_dominator_tree ( start_index ) ? ; let dom_tree_pre_oder = dom_tree . compute_pre_order ( start_index ) ? ; let mut dominators : FxHashMap < usize , FxHashSet < usize > > = FxHashMap :: default ( ) ; for vertex in dom_tree_pre_oder { let mut doms = FxHashSet :: default ( ) ; doms . insert ( vertex ) ; for pred in & dom_tree . predecessors [ & vertex ] { doms . extend ( & dominators [ pred ] ) } dominators . insert ( vertex , doms ) ; } Ok ( dominators ) }
Computes dominators for all vertices in the graph
Computes dominators for all vertices in the graph
&self
start_index
usize
&self
start_index
usize