# Are these two circuits equivalent (using swap gates with control qubits)?

Hi. I'm trying to make a circuit including some Toffoli gates in Qiskit.

The problem is that, because of connectivity between qubits, some gates should be modified to satisfy it.

I've read this post similar to this problem: How is it possible to perform a c-not on 4 qubits using the same control qubits on IBM Q computers?

This helped me a lot, but I'm still uncertain that these two circuits are equivalent &

SWAP gates applied to $$q_1, q_2, q_3$$ don't affect after all works are done.

Thanks a lot.

The way that I convinced myself that it was correct was to take each of the qubits $$q_1$$ to $$q_3$$ in turn ($$q_0$$ and $$q_4$$ being obvious). You can go from the start, and trace its effective position through the swaps and check that each of them comes out in the correct place (i.e. the same position as it started) and that what started as $$q_3$$ goes through the control of the Toffoli.