I am interested in finding the permutations p:S->S within a set S={1, 2, ..., n}. In particular, all the functions that either permute i and j: p(i)=j and p(j)=i; or leave them unchanged p(i)=i or p(j)=j.
For instance, if S={1,2,3}, I should get something like:
p0 = [(1), (2), (3)] # p(1)=1, p(2)=2, p(3)=3
p1 = [(1,2), (3)] # p(1)=2, p(2)=1, p(3)=3
p2 = [(1,3), (2)]
p3 = [(2,3), (1)]
If S={1, 2, 3, 4}:
p0 = [(1), (2), (3), (4)]
p1 = [(1,2), (3,4)]
p2 = [(1,2), (3), (4)] # p(1)=2, p(2)=1, p(3)=3, p(4)=4
p3 = [(1,3), (2,4)]
p4 = [(1,3), (2), (4)]
p5 = [(1,4), (2,3)]
p6 = [(1,4), (2), (3)]
p7 = [(1), (3), (2,4)]
p8 = [(1), (4), (2,3)]
p9 = [(1), (2), (3,4)]
Thanks.