CircuitToGraphConverter
- class perceval_interop.qiskit.circuit_to_graph_converter.CircuitToGraphConverter(qiskit_circuit=None, gates=None, qubits=None)
Takes a qiskit circuit and converts it into a graph. Initially get the list of gates and the qubits on which each gate is acting on. With this output or if the user already has the two lists, it converts it into a graph where the vertices are the qubits and the edges the gates acting on them, the weight of its edges depends on the type of gate.
- generate_graph()
The qubits of the circuit are interpreted as nodes. The weight of the edges connecting them will depend on the number and type of gates.
- Return type:
Graph
- graph_k_clustering_and_cnots_needed(compute_with_min_cnots=False)
Computes the laplacian matrix of the graph, compute its eigenvectors sorted by their eigenvalues. For all the possible subpartitions of the graph, it will compute the kmeans clustering with the respective number of eigenvectors as features. Given the random initial state for the kmeans method, the user has the option to compute multiple repetitions and choose the partition that gives the smallest number of CNOTs.
- Parameters:
compute_with_min_cnots (
bool
) – Whether to compute it 30 times and choose the output yielding to the minimum of CNOTs.- Return type:
tuple
[list
[list
[int
]],list
[int
]]- Returns:
Clustering result and CNOT counts.