# A Graph-Based Approach for Modelling Quantum Circuits
## 3 Background on the Unitary Circuit Model  
The unitary circuit model for QC resembles the structure and behaviour of Boolean circuits. It is composed of qubits, unitary quantum gates that manipulate these qubits and lines that define the order in which the gates operate over the qubits. The operation performed by a quantum gate must be unitary, hence the name of this model of computation. This means that not all operations are allowed but only those that are reversible, given that no information is lost in the evolution in time of a closed quantum system. It also requires that gates have the same number of inputs and outputs. Like their Boolean counterparts, quantum circuits are read from left to right.  
Quantum gates (see [25] for a complete and deep discussion) can operate on any number of qubits. Like normal bits in classical computers, qubits are independent of each other, and the computations performed in one of them do not affect or depend on other qubits, unless they participate in the operation defined by a multi-qubit gate. In this case, an execution dependency is created between otherwise independent qubits. Gates that operate on multiple qubits are very important in QC since they create, modify or seize the special properties of entangled states, which are key to unleashing the computational power of QC.  
The graphical notation of quantum circuits is inspired by Penrose graphical notation [26], which provides a graphical representation for mathematical operations with tensors and for multilinear functions. As an example, two circuits that perform the same calculation are shown in Figure 1. As can be seen, only the relative order of gates is important for single-qubit gates, while gates that act on many qubits require that all qubits involved in the computation be in the correct state before the gate can start its operation.  
However, it should be noted that there is order in the execution of a quantum program, as happens in classical programming languages. Firstly, the low-level source code defines a certain order of gate applications. Secondly, quantum transpiers apply many kinds of optimizations and re-ordering of gates to optimize to the qubit topology in certain quantum computers.  
Circuit reversibility is a fundamental requirement in QC because reversibility is a fundamental property of quantum mechanics. Reversibility enables qubits to maintain their properties of superposition and entanglement, and ensures that operations performed on them preserve the information. From a more mathematical perspective, quantum circuits can be seen as functions that take as input a finite string '\(x\)' of n-qubits and output a finite  
Figure 1: Two equivalent quantum circuits that include the Hadamard, NOT, Z, Control-NOT, and Toffoli gates. Only the relative placement of quantum gates and the dependencies in the order of execution created by multi-qubit gates (Control-NOT and Toffoli gates) are important.  
string '\(y\)' of the same length, \(y=f(x)\), where \(f:\{0,1\}^{n}\rightarrow\{0,1\}^{n}\). Given that quantum circuits must be reversible, '\(a\)' qubits of the string will be considered as real inputs to the function, while '\(b\)' qubits will store the output values, where \(n=a+b\). This differentiation between qubits depends entirely on the quantum algorithm being executed. From the point of view of the quantum circuits, there is no difference among qubits.