Skip to content

Commit

Permalink
important fix + new test
Browse files Browse the repository at this point in the history
  • Loading branch information
uniwuni committed Feb 19, 2024
1 parent 6d4d1a4 commit 0518129
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/symmetric_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,15 @@ impl Permutation {
let mut cycles: Vec<Cycle> = vec![];
while let Some(&start) = unvisited.iter().min() {
let mut m: usize = start; // kind of hacky but who care
let mut v: Vec<usize> = vec![];
let mut v: Vec<usize> = vec![start];
let mut b: bool = true;
while m != start || b {
b = false;
m = self[m];
v.push(m);
unvisited.remove(&m);
}
v.pop();
cycles.push(Cycle {
degree: self.degree,
vec: v,
Expand Down Expand Up @@ -535,6 +536,12 @@ mod test {
assert_eq!(Permutation::from(cycle.clone().inv()), grp.inv(&Permutation::from(cycle)));

}
#[test]
fn cycle_decomposes_to_nearly_itself((n, cycle) in Cycle::strategy_up_to(256)) {
if cycle.order() > 1 {assert_eq!(Permutation::from(&cycle).decompose_cycle().iter().filter(|a| a.order() != 1).collect::<Vec<_>>(),
vec![&cycle])};

}
}
proptest! {

Expand Down

0 comments on commit 0518129

Please sign in to comment.