pub fn is_node_cyclic(&self, starting_node_index: NodeIndex) -> bool {
        // This is similar to depth traversal below, but we
        // can't use that, because depth traversal doesn't show
        // the starting node a second time.
        let mut visited = BitVector::new(self.len_nodes());
        let mut stack = vec![starting_node_index];

        while let Some(current_node_index) = stack.pop() {
            visited.insert(current_node_index.0);

            // Directionality doesn't change the answer,
            // so just use outgoing edges.
            for (_, edge) in self.outgoing_edges(current_node_index) {
                let target_node_index = edge.target();

                if target_node_index == starting_node_index {
                    return true;
                }

                if !visited.contains(target_node_index.0) {
                    stack.push(target_node_index);
                }
            }
        }

        false
    }
/// Whether or not a node can be reached from itself.
Whether or not a node can be reached from itself.
Whether or not a node can be reached from itself .
pub fn is_node_cyclic(&self, starting_node_index: NodeIndex) -> bool {
        // This is similar to depth traversal below, but we
        // can't use that, because depth traversal doesn't show
        // the starting node a second time.
        let mut visited = BitVector::new(self.len_nodes());
        let mut stack = vec![starting_node_index];
        while let Some(current_node_index) = stack.pop() {
            visited.insert(current_node_index.0);
            // Directionality doesn't change the answer,
            // so just use outgoing edges.
            for (_, edge) in self.outgoing_edges(current_node_index) {
                let target_node_index = edge.target();
                if target_node_index == starting_node_index {
                    return true;
                }
                if !visited.contains(target_node_index.0) {
                    stack.push(target_node_index);
                }
            }
        }
        false
    }
pub fn is_node_cyclic ( & self , starting_node_index : NodeIndex ) -> bool { // This is similar to depth traversal below, but we // can't use that, because depth traversal doesn't show // the starting node a second time. let mut visited = BitVector :: new ( self . len_nodes ( ) ) ; let mut stack = vec ! [ starting_node_index ] ; while let Some ( current_node_index ) = stack . pop ( ) { visited . insert ( current_node_index . 0 ) ; // Directionality doesn't change the answer, // so just use outgoing edges. for ( _ , edge ) in self . outgoing_edges ( current_node_index ) { let target_node_index = edge . target ( ) ; if target_node_index == starting_node_index { return true ; } if ! visited . contains ( target_node_index . 0 ) { stack . push ( target_node_index ) ; } } } false }
Whether or not a node can be reached from itself.
Whether or not a node can be reached from itself .
&self
starting_node_index
NodeIndex
&self
starting_node_index
NodeIndex