Re: Cyclic permutations
- To: mathgroup at smc.vnet.net
- Subject: [mg79402] Re: [mg79377] Cyclic permutations
- From: anguzman at ing.uchile.cl
- Date: Thu, 26 Jul 2007 05:26:03 -0400 (EDT)
- References: <f7pon7$prc$1@smc.vnet.net><f7sgu2$ss8$1@smc.vnet.net>
Hello:
I think a possible solution could be:
UnionWithoutCycles[lista_List] :=
Union @@ Append[List /@ #,
SameTest -> (MemberQ[
Function[x, RotateLeft[#1, x]] /@
Range[Length[#1]], #2] &)] &[lista]
Seems to work
In[98]:=
UnionWithoutCycles[{{2,3,4},{3,4,2},{a,b,c},{c,b,a},{b,c,a},{0,s},{s,0}}]
Out[98]=
{{0,s},{2,3,4},{a,b,c},{c,b,a}}
The function is straightforward but not fast or efficient. It takes
advantage of the SameTest feature of the Union function. Two elemnts
will considered to be the same if one of them is in the set of all
cyclic permutations of the other. These permutation were obtained
with RotateLeft..
Hope this helps
Atte Andres Guzman
"King, Peter R" <peter.king at imperial.ac.uk> ha escrito:
> I have a set of permutations eg.
>
> {a,b,c,d}, {a,c,b,d} {b,c,d,a}
>
> Some of which are just cyclic variations of others (ie. {b,c,d,a} is a
> cyclic variant of {a,b,c,d}). Is there a simple way of getting rid of
> these, so that the above set just becomes
>
> {a,b,c,d}, {a,c,b,d}
>
> I am quite happy to select the cyclic variant to be kept arbitrarily (or
> using lexical ordering, I'm not particularly concerned).
>
> Thanks in advance for your help.
>
> Peter King
>
> (by the way I am still using version 5.1 so V6 specific methods wouldn't
> help I'm afraid)
>
>
>
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.