pub fn has_path_with_node_excluded(
        &self,
        from: &MuName,
        to: &MuName,
        exclude_node: &MuName
    ) -> bool {
        // we cannot exclude start and end of the path
        assert!(exclude_node != from && exclude_node != to);

        if from == to {
            true
        } else {
            // we are doing BFS

            // visited nodes
            let mut visited: LinkedHashSet<&MuName> = LinkedHashSet::new();
            // work queue
            let mut work_list: Vec<&MuName> = vec![];
            // initialize visited nodes, and work queue
            visited.insert(from);
            work_list.push(from);

            while !work_list.is_empty() {
                let n = work_list.pop().unwrap();
                for succ in self.get_succs(n) {
                    if succ == exclude_node {
                        // we are not going to follow a path with the excluded node
                        continue;
                    } else {
                        // if we are reaching destination, return true
                        if succ == to {
                            return true;
                        }

                        // push succ to work list so we will traverse them later
                        if !visited.contains(succ) {
                            visited.insert(succ);
                            work_list.push(succ);
                        }
                    }
                }
            }

            false
        }
    }
/// checks if there exists a path between from and to, without excluded node
checks if there exists a path between from and to, without excluded node
checks if there exists a path between from and to without excluded node
pub fn has_path_with_node_excluded(
        &self,
        from: &MuName,
        to: &MuName,
        exclude_node: &MuName
    ) -> bool {
        // we cannot exclude start and end of the path
        assert!(exclude_node != from && exclude_node != to);
        if from == to {
            true
        } else {
            // we are doing BFS
            // visited nodes
            let mut visited: LinkedHashSet<&MuName> = LinkedHashSet::new();
            // work queue
            let mut work_list: Vec<&MuName> = vec![];
            // initialize visited nodes, and work queue
            visited.insert(from);
            work_list.push(from);
            while !work_list.is_empty() {
                let n = work_list.pop().unwrap();
                for succ in self.get_succs(n) {
                    if succ == exclude_node {
                        // we are not going to follow a path with the excluded node
                        continue;
                    } else {
                        // if we are reaching destination, return true
                        if succ == to {
                            return true;
                        }
                        // push succ to work list so we will traverse them later
                        if !visited.contains(succ) {
                            visited.insert(succ);
                            work_list.push(succ);
                        }
                    }
                }
            }
            false
        }
    }
pub fn has_path_with_node_excluded ( & self , from : & MuName , to : & MuName , exclude_node : & MuName ) -> bool { // we cannot exclude start and end of the path assert ! ( exclude_node from exclude_node to ) ; if from == to { true } else { // we are doing BFS // visited nodes let mut visited : LinkedHashSet < & MuName > = LinkedHashSet :: new ( ) ; // work queue let mut work_list : Vec < & MuName > = vec ! [ ] ; // initialize visited nodes, and work queue visited . insert ( from ) ; work_list . push ( from ) ; while ! work_list . is_empty ( ) { let n = work_list . pop ( ) . unwrap ( ) ; for succ in self . get_succs ( n ) { if succ == exclude_node { // we are not going to follow a path with the excluded node continue ; } else { // if we are reaching destination, return true if succ == to { return true ; } // push succ to work list so we will traverse them later if ! visited . contains ( succ ) { visited . insert ( succ ) ; work_list . push ( succ ) ; } } } } false } }
checks if there exists a path between from and to, without excluded node
checks if there exists a path between from and to without excluded node
&self
from
&MuName
to
&MuName
exclude_node
&MuName
&self
from
&MuName
to
&MuName
exclude_node
&MuName