Three-CNOT decomposition of the SWAP gate (source code)

= Three-CNOT decomposition of the SWAP gate
{c}

Applying controlled-NOT gates with directions $1\to2$, $2\to1$, and $1\to2$ maps
$$
(x,y)\mapsto(x,x\oplus y)\mapsto(y,x\oplus y)\mapsto(y,x),
$$
and therefore implements the <SWAP gate>.