fn find_worst_pair(&self, leaves: &[Index]) -> (usize, usize) {
        // This would be silly.
        debug_assert!(leaves.len() >= 2);

        let mut worst_pair = None;
        let mut worst_area = std::f64::MIN;

        // find the two leaves of this node that would be the most terrible together
        for (l1_index, node1) in leaves.iter().enumerate() {
            let r1 = &self.nodes[*node1].get_region();
            let a1 = r1.get_area();

            for (l2_index, node2) in leaves.iter().enumerate().skip(l1_index + 1) {
                let r2 = &self.nodes[*node2].get_region();
                let a2 = r2.get_area();

                // combine these two regions together
                let combined_region = r1.combine_region(r2).expect("failed to combine regions");
                let combined_area = combined_region.get_area() - a1 - a2;

                if combined_area > worst_area {
                    worst_pair = Some((l1_index, l2_index));
                    worst_area = combined_area;
                }
            }
        }

        worst_pair.unwrap()
    }
/// Given a set of nodes, finds the pair of nodes whose combined bounding box is
/// the worst.  To be concrete, we find the pair whose combined bounding box
/// has the maximum difference to the sum of the areas of the bounding boxes
/// for the original two nodes.
Given a set of nodes, finds the pair of nodes whose combined bounding box is
the worst.  To be concrete, we find the pair whose combined bounding box
has the maximum difference to the sum of the areas of the bounding boxes
for the original two nodes.
Given a set of nodes finds the pair of nodes whose combined bounding box is the worst . To be concrete we find the pair whose combined bounding box has the maximum difference to the sum of the areas of the bounding boxes for the original two nodes .
fn find_worst_pair(&self, leaves: &[Index]) -> (usize, usize) {
        // This would be silly.
        debug_assert!(leaves.len() >= 2);
        let mut worst_pair = None;
        let mut worst_area = std::f64::MIN;
        // find the two leaves of this node that would be the most terrible together
        for (l1_index, node1) in leaves.iter().enumerate() {
            let r1 = &self.nodes[*node1].get_region();
            let a1 = r1.get_area();
            for (l2_index, node2) in leaves.iter().enumerate().skip(l1_index + 1) {
                let r2 = &self.nodes[*node2].get_region();
                let a2 = r2.get_area();
                // combine these two regions together
                let combined_region = r1.combine_region(r2).expect("failed to combine regions");
                let combined_area = combined_region.get_area() - a1 - a2;
                if combined_area > worst_area {
                    worst_pair = Some((l1_index, l2_index));
                    worst_area = combined_area;
                }
            }
        }
        worst_pair.unwrap()
    }
fn find_worst_pair ( & self , leaves : & [ Index ] ) -> ( usize , usize ) { // This would be silly. debug_assert ! ( leaves len ( ) 2 ) ; let mut worst_pair = None ; let mut worst_area = std :: f64 :: MIN ; // find the two leaves of this node that would be the most terrible together for ( l1_index , node1 ) in leaves . iter ( ) . enumerate ( ) { let r1 = & self . nodes [ * node1 ] . get_region ( ) ; let a1 = r1 . get_area ( ) ; for ( l2_index , node2 ) in leaves . iter ( ) . enumerate ( ) . skip ( l1_index + 1 ) { let r2 = & self . nodes [ * node2 ] . get_region ( ) ; let a2 = r2 . get_area ( ) ; // combine these two regions together let combined_region = r1 . combine_region ( r2 ) . expect ( " " ) ; let combined_area = combined_region . get_area ( ) - a1 - a2 ; if combined_area > worst_area { worst_pair = Some ( ( l1_index , l2_index ) ) ; worst_area = combined_area ; } } } worst_pair . unwrap ( ) }
Given a set of nodes, finds the pair of nodes whose combined bounding box is
the worst.
Given a set of nodes finds the pair of nodes whose combined bounding box is the worst .
&self
leaves
&[Index]
&self
leaves
&[Index]