# A Graph-Based Approach for Modelling Quantum Circuits
## 4 Modelling the Unitary Circuit Model of Quantum Computation
### A Unified Metamodel for the Unitary Circuit Model  
Given the description of the unitary circuit model described in the previous section, an approach based on the use of direct-acyclic graphs (DAGs) seems the most obvious and sensible, be it a metamodel that allows modelling DAGs without constraints, or a restricted version that considers the horizontal or vertical structure inherent to the unitary circuit model. In the second case, the language would consider either some kind of swim-lane abstraction to model the flow of execution of quantum gates over a qubit, like the UML activity diagram used in [17], or some kind of element to model the vertical sections of the circuit, like the metamodel described in [9].  
The metamodel shown in Figure 2 extends the well-known metamodel of graphs to combine all the approaches into a single modelling language. The purpose of this metamodel is to be as simple as possible, providing only the core minimum set of elements that allow users to model quantum circuits. The three meta-classes coloured in yellow represent the original version of a metamodel for graphs, while the extensions needed to model quantum circuits are shown in blue (Qubit and Control gate) and in grey (abstract base meta-class QuantumGate). The control gate allows the creation of multi-qubit gates, which are needed to entangle qubits.  
These six meta-classes, together with their relationships, constitute a minimal core for modelling quantum circuits. Of course, the metamodel should be extended, by inheriting from the abstract base meta-class (QuantumGate) to add all the gates available in the general  
Figure 2: Metamodel for quantum software following the quantum circuit model that can accommodate at least five modelling strategies. The diagram uses the UML class diagram notation, where the cardinality between meta-classes is given with minimum and maximum values (\(*\) means ‘unbounded’). An extended version of this metamodel is shown in Appendix A.  
unitary quantum circuit model. For the sake of simplicity, only two gates, which are needed to model the example quantum circuit described below, have been added to the metamodel (coloured in green): H (the Hadamard gate, to create superposition) and X (the NOT gate). This version is sufficient for the purposes of this paper. The containment relationship between Qubit and QuantumGate, coloured in red in Figure 2, will be justified in Section 5.3 and can be ignored for now.  
It should be clarified that the metamodel allows the modelling of multi-controlled gates, i.e., gates controlled by more than one qubit. To do this, it is necessary to include as many Control gates as needed and set their _controlGate_ property to the gate they control.  
The metamodel also makes it possible to model more complex structures that appear in quantum programmes, such as a Quantum Random Access Memory (QRAM) [27]. Following the Bucket Brigade architecture [28] or a more recent circuit design [29], since QRAMs are implemented by means of quantum gates, they can be modelled with the proposed metamodel and stored in their own files, independently from the rest of the quantum circuit. In this way, they could be reused as modules in multiple programs where QRAMs are needed.