The function generates the elements of a bracelet which are in equivalence relation with the vector given in input. The first parameter is the input vector. If the second parameter (bOut) is set equal to TRUE,
the function produces a compact result.
Example: cBracelets(c(1,0,2,1)) produces the following result:
|
[1] 0 1 1 2 |
[1] 0 2 1 1 |
[1] 1 0 2 1 |
[1] 1 1 0 2 |
[1] 1 1 2 0 |
[1] 1 2 0 1 |
[1] 2 0 1 1 |
[1] 2 1 1 0 |
|
cBracelets(c(1,0,2,1),TRUE) produces the following result:
|
[ 0 1 1 2 ] ( 1 ) |
[ 0 2 1 1 ] ( 2 ) |
[ 1 0 2 1 ] ( 3 ) |
[ 1 1 0 2 ] ( 4 ) |
[ 1 1 2 0 ] ( 5 ) |
[ 1 2 0 1 ] ( 6 ) |
[ 2 0 1 1 ] ( 7 ) |
[ 2 1 1 0 ] ( 8 ) |
|
Note that 0 1 1 2 is the representative of the class, that is the minimum in lexicographical order.