qiskit.converters.circuit_to_dag¶
- circuit_to_dag(circuit, copy_operations=True)[ソース]¶
Build a
DAGCircuit
object from aQuantumCircuit
.- パラメータ
circuit (QuantumCircuit) – the input circuit.
copy_operations (bool) – Deep copy the operation objects in the
QuantumCircuit
for the outputDAGCircuit
. This should only be set toFalse
if the inputQuantumCircuit
will not be used anymore as the operations in the outputDAGCircuit
will be shared instances and modifications to operations in theDAGCircuit
will be reflected in theQuantumCircuit
(and vice versa).
- 戻り値
the DAG representing the input circuit.
- 戻り値の型
サンプル
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit from qiskit.dagcircuit import DAGCircuit from qiskit.converters import circuit_to_dag q = QuantumRegister(3, 'q') c = ClassicalRegister(3, 'c') circ = QuantumCircuit(q, c) circ.h(q[0]) circ.cx(q[0], q[1]) circ.measure(q[0], c[0]) circ.rz(0.5, q[1]).c_if(c, 2) dag = circuit_to_dag(circ)