pub fn group_layers(&self) -> Vec<Vec<usize>> {
        let ranks = self.layout();
        let mut pairs: Vec<(usize, usize)> = ranks
            .iter()
            .enumerate()
            .map(|(nodei, &rank)| (rank, nodei))
            .collect();
        pairs.sort_by_key(|p| p.0);
        pairs.reverse();

        let mut layers = Vec::new();

        let (mut current_rank, first_node) = pairs.pop().unwrap();
        let mut layer = vec![first_node];

        while let Some((rank, nodei)) = pairs.pop() {
            assert!(rank >= current_rank);
            if rank == current_rank {
                layer.push(nodei);
            } else {
                assert!(layer.len() > 0);
                layers.push(layer);
                layer = vec![nodei];
                current_rank = rank;
            }
        }
        assert!(layer.len() > 0);
        layers.push(layer);

        for layer in layers.iter_mut() {
            layer.sort();
        }

        layers
    }
/// Group the nodes into layers.
Group the nodes into layers.
Group the nodes into layers .
pub fn group_layers(&self) -> Vec<Vec<usize>> {
        let ranks = self.layout();
        let mut pairs: Vec<(usize, usize)> = ranks
            .iter()
            .enumerate()
            .map(|(nodei, &rank)| (rank, nodei))
            .collect();
        pairs.sort_by_key(|p| p.0);
        pairs.reverse();
        let mut layers = Vec::new();
        let (mut current_rank, first_node) = pairs.pop().unwrap();
        let mut layer = vec![first_node];
        while let Some((rank, nodei)) = pairs.pop() {
            assert!(rank >= current_rank);
            if rank == current_rank {
                layer.push(nodei);
            } else {
                assert!(layer.len() > 0);
                layers.push(layer);
                layer = vec![nodei];
                current_rank = rank;
            }
        }
        assert!(layer.len() > 0);
        layers.push(layer);
        for layer in layers.iter_mut() {
            layer.sort();
        }
        layers
    }
pub fn group_layers ( & self ) -> Vec < Vec < usize > > { let ranks = self . layout ( ) ; let mut pairs : Vec < ( usize , usize ) > = ranks . iter ( ) . enumerate ( ) . map ( | ( nodei , & rank ) | ( rank , nodei ) ) . collect ( ) ; pairs . sort_by_key ( | p | p . 0 ) ; pairs . reverse ( ) ; let mut layers = Vec :: new ( ) ; let ( mut current_rank , first_node ) = pairs . pop ( ) . unwrap ( ) ; let mut layer = vec ! [ first_node ] ; while let Some ( ( rank , nodei ) ) = pairs . pop ( ) { assert ! ( rank current_rank ) ; if rank == current_rank { layer . push ( nodei ) ; } else { assert ! ( layer len ( ) 0 ) ; layers . push ( layer ) ; layer = vec ! [ nodei ] ; current_rank = rank ; } } assert ! ( layer len ( ) 0 ) ; layers . push ( layer ) ; for layer in layers . iter_mut ( ) { layer . sort ( ) ; } layers }
Group the nodes into layers.
Group the nodes into layers .
&self
&self