The function generates the elements of a necklace 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: cNecklaces(c(1,0,2,1))
produces the following result:
|
[1] 0 2 1 1 |
[1] 1 0 2 1 |
[1] 1 1 0 2 |
[1] 2 1 1 0 |
|
cNecklaces(c(1,0,2,1),TRUE)
produces the following result:
|
[ 0 2 1 1 ] ( 1 ) |
[ 1 0 2 1 ] ( 2 ) |
[ 1 1 0 2 ] ( 3 ) |
[ 2 1 1 0 ] ( 4 ) |
|
Note that 0 2 1 1
is the representative of the class, that is the minimum in lexicographical order.