fn root(&mut self, id: usize) -> usize {
        let mut root = id;
        while root != self.nodes[id] {
            // make every other node in path point to its grandparent
            self.nodes[root] = self.nodes[self.nodes[root]];
            root = self.nodes[id];
        }
        root
    }
/// Returns the root of the given node.
/// 
/// # Arguments
/// * `id` ID of the child node.
Returns the root of the given node.
Returns the root of the given node .
fn root(&mut self, id: usize) -> usize {
        let mut root = id;
        while root != self.nodes[id] {
            // make every other node in path point to its grandparent
            self.nodes[root] = self.nodes[self.nodes[root]];
            root = self.nodes[id];
        }
        root
    }
fn root ( & mut self , id : usize ) -> usize { let mut root = id ; while root != self . nodes [ id ] { // make every other node in path point to its grandparent self . nodes [ root ] = self . nodes [ self . nodes [ root ] ] ; root = self . nodes [ id ] ; } root }
Returns the root of the given node.
Returns the root of the given node .
&mut self
id
usize
&mut self
id
usize