I am trying to use this function github.com/Qiskit/qiskit-terra/blob/master/qiskit/transpiler/passes/routing/basic_swap.py and it take a DAG as input. The output is also a DAG, so I am trying to convert it back to usual QuantumCircuit
I am trying to use this function github.com/Qiskit/qiskit-terra/blob/master/qiskit/transpiler/passes/routing/basic_swap.py and it take a DAG as input. The output is also a DAG, so I am trying to convert it back to usual QuantumCircuit
You can use the qiskit.converters
module which includes (among others):
qiskit.converters.circuit_to_dag()
: qiskit.org/documentation/stubs/qiskit.converters.circuit_to_dag.html?highlight=dag#qiskit.converters.circuit_to_dag
qiskit.converters.dag_to_circuit()
: qiskit.org/documentation/stubs/qiskit.converters.dag_to_circuit.html?highlight=dag#qiskit.converters.dag_to_circuit
And if you are trying to perform the basic_swap on a circuit, you can also do:
swap_pass = BasicSwap(coupling_map)
swapped_circuit = swap_pass(circuit)