/// Merge cycles that share any vertex in a given set of cycles.
Merge cycles that share any vertex in a given set of cycles.
Merge cycles that share any vertex in a given set of cycles .
pub fn merge_cycles(
    cycles: &Vec<Vec<usize>>
) -> Vec<Vec<usize>> {
    let mut isolated_cycles: Vec<Vec<usize>> = vec![];
    let mut cycles_cloned = cycles.to_vec();
    while cycles_cloned.len() > 0 {
        if let Some(mut cycle) = cycles_cloned.pop() {
            let mut is_isolated: bool = true;
            for idx in 0..cycles_cloned.len() {
                if orbit_ops::orbit_overlap(&cycle, &cycles_cloned[idx]) {
                    is_isolated = false;
                    cycles_cloned[idx].append(&mut cycle);
                    cycles_cloned[idx].sort_unstable();
                    cycles_cloned[idx].dedup();
                    break;
                }
            }
            if is_isolated {
                isolated_cycles.push(cycle);
            }
        }
    }
    isolated_cycles
}
pub fn merge_cycles ( cycles : & Vec < Vec < usize > > ) -> Vec < Vec < usize > > { let mut isolated_cycles : Vec < Vec < usize > > = vec ! [ ] ; let mut cycles_cloned = cycles . to_vec ( ) ; while cycles_cloned . len ( ) > 0 { if let Some ( mut cycle ) = cycles_cloned . pop ( ) { let mut is_isolated : bool = true ; for idx in 0 .. cycles_cloned . len ( ) { if orbit_ops :: orbit_overlap ( & cycle , & cycles_cloned [ idx ] ) { is_isolated = false ; cycles_cloned [ idx ] . append ( & mut cycle ) ; cycles_cloned [ idx ] . sort_unstable ( ) ; cycles_cloned [ idx ] . dedup ( ) ; break ; } } if is_isolated { isolated_cycles . push ( cycle ) ; } } } isolated_cycles }
Merge cycles that share any vertex in a given set of cycles.
Merge cycles that share any vertex in a given set of cycles .
cycles
&Vec<Vec<usize>>