|
@@ -20,9 +20,9 @@ void permutation::transpose(int i, int j) {
|
|
|
|
|
|
// TODO rapport : dire qu'on garde l'invariant pi[0] = 0
|
|
|
void permutation::random() {
|
|
|
- // Knuth shuffle
|
|
|
+ // Knuth Fisher Yates shuffle
|
|
|
// there is a bias due to the use of rand()%_
|
|
|
- for(int i = 1; i < size; i++)
|
|
|
+ for(int i = size-1; i > 1; i--)
|
|
|
transpose(i, 1+rand()%i);
|
|
|
}
|
|
|
|