Generating permutations using swaps of adjacent elements 
Is it possible to generate all permutations of order n in a sequence
by successive swaps of adjacent elements only, such that each
permutation appears exactly once?

for example, for n = 3 (* denotes the next swap): $$ 1*2-3 $$$$ 2-1*3 $$$$ 2*3-1
 $$$$ 3-2*1 $$$$ 3*1-2 $$$$ 1-3*2 $$
for n = 4, there is a pattern of length 8 that repeats 3 times:
$$ 1*2-3-4 $$$$ 2-1*3-4 $$$$ 2-3-1*4 $$$$ 2-3*4-1 $$$$ 2-4-3*1 $$$$ 2-4*1-3 $$$$ 2*1-4-3 $$$$ 1-2*4-3 $$
Also, the patterns themselves got me curious. Is there a way to generate them?
 A: Yes! You are asking if the cayley graph of the symmetric group with a basis of transpositions is hamiltonian.
In fact this is true, and was proven in Kompel'makher and Liskovet's "Sequential Generation of Arrangements by Means of a Basis of Transpositions".
This is only a 5-page paper, and a fairly easy read. Moreover, it describes an algorithm for finding these cycles using only the swaps $(1,i)$ for $2 \leq i \leq n$, the so called "star-shaped basis".

I hope this helps ^_^
A: It is possible to generate the permutations in this way by using recursion.
$S_1 = \{1_\text{identity}\}$
$S_2 = S_1 \cup [S_1 \circ (1 \; 2)]$
$S_3 = S_2 \cup [S_2 \circ (1 \; 3)] \cup [S_2 \circ (2 \; 3)]$
$S_4 = S_3 \cup [S_3 \circ (1 \; 4)] \cup [S_3 \circ (1 \; 4) \circ (1 \; 2) ]\cup [S_3 \circ (3 \; 4)]$
$S_5 = S_4 \cup [S_4 \circ (1 \; 5)] \cup [S_4 \circ (1 \; 5) \circ (1 \; 2) ] \cup [S_4 \circ (4 \; 5) \circ (3 \; 4)] \cup [S_4 \circ (4 \; 5)]$
$S_6 = S_5 \cup [S_4 \circ (1 \; 6)] \cup [S_5 \circ (1 \; 6) \circ (1 \; 2) ]  \cup [S_5 \circ (1 \; 6) \circ (1 \; 2) \circ (2 \; 3) ]\, \cup$
$\quad \quad \quad \quad\;\, [S_5 \circ (5 \; 6) \circ (4 \; 5)] \cup [S_5 \circ (5 \; 6)]$
$\text{...}$
