mirror of https://github.com/Qiskit/qiskit.git
28 lines
1.1 KiB
YAML
28 lines
1.1 KiB
YAML
---
|
|
features:
|
|
- |
|
|
Added :meth:`.DAGCircuit.classical_predecessors` and
|
|
:meth:`.DAGCircuit.classical_successors`, an alternative to select the classical
|
|
wires without having to go to the inner graph object directly of a node in the DAG.
|
|
The following example illustrates the new functionality::
|
|
|
|
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
|
|
from qiskit.converters import circuit_to_dag
|
|
from qiskit.circuit.library import RZGate
|
|
|
|
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)
|
|
circ.measure(q[1], c[0])
|
|
dag = circuit_to_dag(circ)
|
|
|
|
rz_node = dag.op_nodes(RZGate)[0]
|
|
# Contains the "measure" on clbit 0, and the "wire start" nodes for clbits 1 and 2.
|
|
classical_predecessors = list(dag.classical_predecessors(rz_node))
|
|
# Contains the "measure" on clbit 0, and the "wire end" nodes for clbits 1 and 2.
|
|
classical_successors = list(dag.classical_successors(rz_node))
|