pub fn remove_vertex(&mut self, index: usize) -> Result<()> {
        // TODO there's a lot of duplicated work in removing edges. Makes
        // debugging easier, but could be made much more efficient.
        if !self.has_vertex(index) {
            bail!("vertex does not exist");
        }

        // remove this vertex
        self.vertices.remove(&index);

        // find all edges that deal with this vertex
        let mut edges = FxHashSet::default();
        if let Some(successors) = self.successors.get(&index) {
            for successor in successors {
                edges.insert((index, *successor));
            }
        };
        if let Some(predecessors) = self.predecessors.get(&index) {
            for predecessor in predecessors {
                edges.insert((*predecessor, index));
            }
        };

        // remove all of those edges
        for edge in edges {
            self.remove_edge(edge.0, edge.1)?;
        }

        self.predecessors.remove(&index);
        self.successors.remove(&index);

        Ok(())
    }
/// Removes a vertex, and all edges associated with that vertex.
Removes a vertex, and all edges associated with that vertex.
Removes a vertex and all edges associated with that vertex .
pub fn remove_vertex(&mut self, index: usize) -> Result<()> {
        // TODO there's a lot of duplicated work in removing edges. Makes
        // debugging easier, but could be made much more efficient.
        if !self.has_vertex(index) {
            bail!("vertex does not exist");
        }
        // remove this vertex
        self.vertices.remove(&index);
        // find all edges that deal with this vertex
        let mut edges = FxHashSet::default();
        if let Some(successors) = self.successors.get(&index) {
            for successor in successors {
                edges.insert((index, *successor));
            }
        };
        if let Some(predecessors) = self.predecessors.get(&index) {
            for predecessor in predecessors {
                edges.insert((*predecessor, index));
            }
        };
        // remove all of those edges
        for edge in edges {
            self.remove_edge(edge.0, edge.1)?;
        }
        self.predecessors.remove(&index);
        self.successors.remove(&index);
        Ok(())
    }
pub fn remove_vertex ( & mut self , index : usize ) -> Result < ( ) > { // TODO there's a lot of duplicated work in removing edges. Makes // debugging easier, but could be made much more efficient. if ! self . has_vertex ( index ) { bail ! ( " " ) ; } // remove this vertex self . vertices . remove ( & index ) ; // find all edges that deal with this vertex let mut edges = FxHashSet :: default ( ) ; if let Some ( successors ) = self . successors . get ( & index ) { for successor in successors { edges . insert ( ( index , * successor ) ) ; } } ; if let Some ( predecessors ) = self . predecessors . get ( & index ) { for predecessor in predecessors { edges . insert ( ( * predecessor , index ) ) ; } } ; // remove all of those edges for edge in edges { self . remove_edge ( edge . 0 , edge . 1 ) ? ; } self . predecessors . remove ( & index ) ; self . successors . remove ( & index ) ; Ok ( ( ) ) }
Removes a vertex, and all edges associated with that vertex.
Removes a vertex and all edges associated with that vertex .
&mut self
index
usize
&mut self
index
usize