pub fn remove_node(&mut self, a: NodeIndex) -> Option<N> {
        self.nodes.get(a.index())?;
        for d in &DIRECTIONS {
            let k = *d as usize;

            // Remove all edges from and to this node.
            loop {
                let next = self.nodes[a.index()].next[k];
                if next == EdgeIndex::end() {
                    break;
                }
                let ret = self.remove_edge(next);
                debug_assert!(ret.is_some());
                let _ = ret;
            }
        }

        // Use swap_remove -- only the swapped-in node is going to change
        // NodeIndex, so we only have to walk its edges and update them.

        let node = self.nodes.swap_remove(a.index());

        // Find the edge lists of the node that had to relocate.
        // It may be that no node had to relocate, then we are done already.
        let swap_edges = match self.nodes.get(a.index()) {
            None => return Some(node.weight),
            Some(ed) => ed.next,
        };

        // The swapped element's old index
        let old_index = NodeIndex::new(self.nodes.len() as u32);
        let new_index = a;

        // Adjust the starts of the out edges, and ends of the in edges.
        for &d in &DIRECTIONS {
            let k = d as usize;
            let mut edges = edges_walker_mut(&mut self.edges, swap_edges[k], d);
            while let Some(curedge) = edges.next_edge() {
                debug_assert!(curedge.node[k] == old_index);
                curedge.node[k] = new_index;
            }
        }
        Some(node.weight)
    }
/// Remove `a` from the graph if it exists, and return its weight.
/// If it doesn't exist in the graph, return `None`.
///
/// Apart from `a`, this invalidates the last node index in the graph
/// (that node will adopt the removed node index). Edge indices are
/// invalidated as they would be following the removal of each edge
/// with an endpoint in `a`.
///
/// Computes in **O(e')** time, where **e'** is the number of affected
/// edges, including *n* calls to `.remove_edge()` where *n* is the number
/// of edges with an endpoint in `a`, and including the edges with an
/// endpoint in the displaced node.
Remove `a` from the graph if it exists, and return its weight.
If it doesn't exist in the graph, return `None`.

Apart from `a`, this invalidates the last node index in the graph
(that node will adopt the removed node index). Edge indices are
invalidated as they would be following the removal of each edge
with an endpoint in `a`.


Remove ` a ` from the graph if it exists and return its weight . If it doesn ' t exist in the graph return ` None ` . Apart from ` a ` this invalidates the last node index in the graph ( that node will adopt the removed node index ) . Edge indices are invalidated as they would be following the removal of each edge with an endpoint in ` a ` .
pub fn remove_node(&mut self, a: NodeIndex) -> Option<N> {
        self.nodes.get(a.index())?;
        for d in &DIRECTIONS {
            let k = *d as usize;
            // Remove all edges from and to this node.
            loop {
                let next = self.nodes[a.index()].next[k];
                if next == EdgeIndex::end() {
                    break;
                }
                let ret = self.remove_edge(next);
                debug_assert!(ret.is_some());
                let _ = ret;
            }
        }
        // Use swap_remove -- only the swapped-in node is going to change
        // NodeIndex, so we only have to walk its edges and update them.
        let node = self.nodes.swap_remove(a.index());
        // Find the edge lists of the node that had to relocate.
        // It may be that no node had to relocate, then we are done already.
        let swap_edges = match self.nodes.get(a.index()) {
            None => return Some(node.weight),
            Some(ed) => ed.next,
        };
        // The swapped element's old index
        let old_index = NodeIndex::new(self.nodes.len() as u32);
        let new_index = a;
        // Adjust the starts of the out edges, and ends of the in edges.
        for &d in &DIRECTIONS {
            let k = d as usize;
            let mut edges = edges_walker_mut(&mut self.edges, swap_edges[k], d);
            while let Some(curedge) = edges.next_edge() {
                debug_assert!(curedge.node[k] == old_index);
                curedge.node[k] = new_index;
            }
        }
        Some(node.weight)
    }
pub fn remove_node ( & mut self , a : NodeIndex ) -> Option < N > { self . nodes . get ( a . index ( ) ) ? ; for d in & DIRECTIONS { let k = * d as usize ; // Remove all edges from and to this node. loop { let next = self . nodes [ a . index ( ) ] . next [ k ] ; if next == EdgeIndex :: end ( ) { break ; } let ret = self . remove_edge ( next ) ; debug_assert ! ( ret is_some ( ) ) ; let _ = ret ; } } // Use swap_remove -- only the swapped-in node is going to change // NodeIndex, so we only have to walk its edges and update them. let node = self . nodes . swap_remove ( a . index ( ) ) ; // Find the edge lists of the node that had to relocate. // It may be that no node had to relocate, then we are done already. let swap_edges = match self . nodes . get ( a . index ( ) ) { None => return Some ( node . weight ) , Some ( ed ) => ed . next , } ; // The swapped element's old index let old_index = NodeIndex :: new ( self . nodes . len ( ) as u32 ) ; let new_index = a ; // Adjust the starts of the out edges, and ends of the in edges. for & d in & DIRECTIONS { let k = d as usize ; let mut edges = edges_walker_mut ( & mut self . edges , swap_edges [ k ] , d ) ; while let Some ( curedge ) = edges . next_edge ( ) { debug_assert ! ( curedge node [ k ] old_index ) ; curedge . node [ k ] = new_index ; } } Some ( node . weight ) }
Remove `a` from the graph if it exists, and return its weight.
Remove ` a ` from the graph if it exists and return its weight .
&mut self
a
NodeIndex