pub fn is_reducible(&self, head: usize) -> Result<bool> {
        let back_edges = self.compute_back_edges(head)?;

        // Build a graph without back edges, a.k.a. forward edges (FE) graph.
        let mut fe_graph = Graph::new();
        for index in self.vertices.keys() {
            fe_graph.insert_vertex(NullVertex::new(*index))?;
        }
        for edge in self.edges.keys() {
            if !back_edges.contains(edge) {
                fe_graph.insert_edge(NullEdge::new(edge.0, edge.1))?;
            }
        }

        // Graph is reducible iff the FE graph is acyclic and every node is reachable from head.
        let every_node_is_reachable = fe_graph.unreachable_vertices(head)?.is_empty();
        Ok(every_node_is_reachable && fe_graph.is_acyclic(head))
    }
/// Determines if the graph is reducible.
Determines if the graph is reducible.
Determines if the graph is reducible .
pub fn is_reducible(&self, head: usize) -> Result<bool> {
        let back_edges = self.compute_back_edges(head)?;
        // Build a graph without back edges, a.k.a. forward edges (FE) graph.
        let mut fe_graph = Graph::new();
        for index in self.vertices.keys() {
            fe_graph.insert_vertex(NullVertex::new(*index))?;
        }
        for edge in self.edges.keys() {
            if !back_edges.contains(edge) {
                fe_graph.insert_edge(NullEdge::new(edge.0, edge.1))?;
            }
        }
        // Graph is reducible iff the FE graph is acyclic and every node is reachable from head.
        let every_node_is_reachable = fe_graph.unreachable_vertices(head)?.is_empty();
        Ok(every_node_is_reachable && fe_graph.is_acyclic(head))
    }
pub fn is_reducible ( & self , head : usize ) -> Result < bool > { let back_edges = self . compute_back_edges ( head ) ? ; // Build a graph without back edges, a.k.a. forward edges (FE) graph. let mut fe_graph = Graph :: new ( ) ; for index in self . vertices . keys ( ) { fe_graph . insert_vertex ( NullVertex :: new ( * index ) ) ? ; } for edge in self . edges . keys ( ) { if ! back_edges . contains ( edge ) { fe_graph . insert_edge ( NullEdge :: new ( edge . 0 , edge . 1 ) ) ? ; } } // Graph is reducible iff the FE graph is acyclic and every node is reachable from head. let every_node_is_reachable = fe_graph . unreachable_vertices ( head ) ? . is_empty ( ) ; Ok ( every_node_is_reachable && fe_graph . is_acyclic ( head ) ) }
Determines if the graph is reducible.
Determines if the graph is reducible .
&self
head
usize
&self
head
usize