# A Graph-Based Approach for Modelling Quantum Circuits
## 5 Supporting Tools and Model Transformations
### Transformation between the Modelling Strategies  
The five modelling strategies described above cover all the modelling proposals identified in the literature (and add three new ones), while using the same metamodel. This contribution offers a number of advantages. The first and most important is that it provides a common set of concepts and modelling elements that can be used to express different ways of thinking about and representing quantum circuits. In addition, the uniqueness of the metamodel allows for the simplification of the development, deployment and maintenance of modelling tools. This will allow the community to \"speak and understand\" the same language, while at the same time supporting some local variations. In addition, the approach allows the development of model-to-model transformations that change the strategy used in each quantum circuit, opening up the possibility of using the most appropriate strategy when developing further model-processing tools. Forinstance, code generation is easier in the \"slice\" strategy, but a per-qubit navigation of a model following this strategy is not as easy as the \"swim-lane\" one. Thus, a model could be transformed from one strategy into another in order to make some tasks easier. An outline of the model-to-model transformation between the strategies follows:  
* The strategies \"swim-lane\" and \"mixed swim-lane\" are basically the same, except that the second one groups together in a single Node all the gates involved in a multi-qubit operation. Therefore, the transformation between both strategies relies on grouping and ungrouping the multi-qubit gates and adding or removing Edges connecting gates operating on the same qubit as needed. The correspondence between the two strategies is 1-to-1. * The \"slice\" strategy can be transformed into/from either the \"swim-lane\" or \"mixed swim-lane\" ones by realising that a given slice (Node) contains gates operating over different qubits. Thus, it is possible to generate the \"swim-lane\" version by creating Nodes containing only one gate and creating Edges connecting the Nodes containing gates operating over the same Qubit, in the order defined by the input circuit. The same procedure applies to generating a model that follows the \"mixed\" strategy but, in this case, controlled gates must be stored in the same Node. Again, the correspondence between these strategies is 1-to-1. * The strategies \"linear\" and \"mixed linear\" are the most flexible ones in the sense that the same quantum circuit can be modelled by several such graphs, simply by changing the relative order of the Nodes in the line, with the only restriction that if two Nodes contain gates that operate on the same qubit, they cannot be interchanged. As in the first case, the transformation between both strategies relies on grouping and ungrouping the multi-qubit gates contained in Nodes, according to the target strategy. When transforming between strategies \"linear\" and \"swim-lane\", the transformation only has to reconFigure Edges according to the Qubit the Nodes (the QuantumGate contained in the Node, to be precise) they link operate over. The transformation from \"mixed linear\" to \"swim-lane\" also requires that the gates contained in Nodes must be ungrouped or grouped, respectively, and as described above, depending on the direction of the transformation. For the strategies \"slice\" and \"mixed\", the transformation must first rearrange the gates in Nodes according to the chosen strategy, remove the ones that remain empty, and then link the Nodes as described in the previous sentence. In any case, given the flexibility of these strategies regarding the order of the Nodes in the graph, the correspondence with the other strategies is n-to-1.