pub fn dag_transitive_closure<G>(graph: G) -> HashMap<G::NodeId, IxBitSet<G::NodeId>>
where
    G: IntoNeighbors + IntoNodeIdentifiers + Visitable,
    G::NodeId: IndexLike + Hash + Eq,
{
    // https://algowiki-project.org/en/Purdom%27s_algorithm#Implementation_scheme_of_the_serial_algorithm
    // Stage 3: transitive closure of directed acyclic graph

    let mut ret = HashMap::new();

    let mut dfspo = DfsPostOrder::empty(graph).iter(graph);
    for n in graph.node_identifiers() {
        if !dfspo.inner_ref().discovered.is_visited(&n) {
            dfspo.inner_mut().move_to(n);
            for v in &mut dfspo {
                let mut ret_v = IxBitSet::new();
                ret_v.insert(v);
                for w in graph.neighbors(v) {
                    ret_v.union_with(&ret[&w]);
                }
                ret.insert(v, ret_v);
            }
        }
    }

    ret
}
/// Computes the transitive closure of the given directed acyclic graph.
/// Returns, for each node, the set of nodes reachable from that node.
Computes the transitive closure of the given directed acyclic graph.
Returns, for each node, the set of nodes reachable from that node.
Computes the transitive closure of the given directed acyclic graph . Returns for each node the set of nodes reachable from that node .
pub fn dag_transitive_closure<G>(graph: G) -> HashMap<G::NodeId, IxBitSet<G::NodeId>>
where
    G: IntoNeighbors + IntoNodeIdentifiers + Visitable,
    G::NodeId: IndexLike + Hash + Eq,
{
    // https://algowiki-project.org/en/Purdom%27s_algorithm#Implementation_scheme_of_the_serial_algorithm
    // Stage 3: transitive closure of directed acyclic graph
    let mut ret = HashMap::new();
    let mut dfspo = DfsPostOrder::empty(graph).iter(graph);
    for n in graph.node_identifiers() {
        if !dfspo.inner_ref().discovered.is_visited(&n) {
            dfspo.inner_mut().move_to(n);
            for v in &mut dfspo {
                let mut ret_v = IxBitSet::new();
                ret_v.insert(v);
                for w in graph.neighbors(v) {
                    ret_v.union_with(&ret[&w]);
                }
                ret.insert(v, ret_v);
            }
        }
    }
    ret
}
pub fn dag_transitive_closure < G > ( graph : G ) -> HashMap < G :: NodeId , IxBitSet < G :: NodeId > > where G : IntoNeighbors + IntoNodeIdentifiers + Visitable , G :: NodeId : IndexLike + Hash + Eq , { // https://algowiki-project.org/en/Purdom%27s_algorithm#Implementation_scheme_of_the_serial_algorithm // Stage 3: transitive closure of directed acyclic graph let mut ret = HashMap :: new ( ) ; let mut dfspo = DfsPostOrder :: empty ( graph ) . iter ( graph ) ; for n in graph . node_identifiers ( ) { if ! dfspo . inner_ref ( ) . discovered . is_visited ( & n ) { dfspo . inner_mut ( ) . move_to ( n ) ; for v in & mut dfspo { let mut ret_v = IxBitSet :: new ( ) ; ret_v . insert ( v ) ; for w in graph . neighbors ( v ) { ret_v . union_with ( & ret [ & w ] ) ; } ret . insert ( v , ret_v ) ; } } } ret }
Computes the transitive closure of the given directed acyclic graph.
Computes the transitive closure of the given directed acyclic graph .
graph
G
graph
G