Failure-Resilient Eulerian graph Encoding (for) Quantum tOurs.
The reason behind this tool is to implement the algorithm we introduced in the paper Directed Graph Encoding in Quantum Computing Supporting Edge-Failure, available here or inside this repository.
In particular, the main procedure takes as input a multigraph G and a family of unitary matrices U and produces a unitary matrix encoding G.
Download the project, making sure to have an up-to-date python version installed in your pc.
Unzip the file and just run the command:
python Main.py
Main.py
takes the input from the file named input.txt
. In order to get the input from another point, do the following operations:
- Find the file
Main.py
and open it with a text editor - Locate this line of code
file_name = "input.txt"
- Change
input.txt
with absolute / relative path to the file you have placed the input in.
For example, to get the input from "different_input.txt"
, the line of code should look like this:
file_name = "different_input.txt"
In order for the input to be parsed, it must be written using a specific form.
-
The first line must contain the number of nodes inside the graph. We will denote such value with n
-
The following n lines have the following syntax:
u : u1, u2, ..., uk
where u is a node name and u1, u2, ..., uk are u's neighbours in the multigraph. In order to obtain a multigraph, for example G where there are two edges between u and v, just write u : v, v. Notice that each one of the n different lines should refer to a different node (no controls have been implemented to check repeated nodes in the input reading).
Moreover, there is no particular rule for the node naming convention. Just make sure to use the same names in the matrix definition phase. -
Then a natural number R is expected
-
The following R lines must have the following form:
[list of comma separated nodes] : M
which has to be interpreted as follows: for all the nodes in the list, the unitary matrix to be applied during the unitarize procedure is M. This syntax is due to the fact that each node in the inital graph G, induces a specific submatrix inside the adjacency matrix of G's line graph. In the unitarize procedure we substitute each one of this submatrix with a unitary matrix. Hence, per each node, we must know which unitary to use. In the case some nodes have no unitary defined, the matrix representing the Discrete Fourier Transform (DFT) will be used as replacement. As a special case, if R is zero, all submatrices will be susbtituted with the DFT. The syntax for the matrix M is the following: write each row of the matrix separating the elements with a space. Then each row is separated from the next one with a semicolon. Moreover, when using complex numbers, rember that in python the imaginary unit is written as j and not i. For example, the matrix for the Y gate is:0 -1j; j 0
However, the file src/input.txt
provides an example of well formatted input.
The program will output some informative lines to tell the keep the user updated on the algorithm stages. Once the procedure is completed, the unitary matrix obtained is printed. The standard output channel is the console, so no automatica redirection to output file is done.
We also developed a web-based interactive version of FREEQO. Check it out here.