-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DAGCircuit: Add get_causal_cone method (#10325)
* Feat: Add `get_causal_node` to `DAGCircuit`: - Also added `get_qubit_input_node` and `get_qubit_output_node`. * Test: Added tests to `dagcircuit.py` * Docs: Added release note * Chore: Remove type-checking in `dagcircuit.py` - Type checking was causing strange behavior during linting. * Added changes to speed up get_causal_cone (#1) - Replace lists with deque for the iteration. * Docs: Modify docstring and release note * Fix: Wrong comparison in `_get_input_output_node` * Remove: input and output node methods. * Lint: Fixed formatting * Docs: Fixed release-note * Docs: Fixed docstring and release note. * Fix: Output map double-lookup. * Docs: Fix inline comments. * Test: Added test for circuits with barriers * Refactor: rename to `quantum_causal_cone` * FIx: Use quantum_sucessors and docstring --------- Co-authored-by: danielleodigie <[email protected]>
- Loading branch information
1 parent
35f9e7c
commit 90c2fe6
Showing
3 changed files
with
231 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
releasenotes/notes/add-dag-causal-cone-5a19311e40fbb3af.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
features: | ||
- | | ||
Added :meth:`.DAGCircuit.quantum_causal_cone` to obtain the causal cone of a qubit | ||
in a :class:`~.DAGCircuit`. | ||
The following example shows its correct usage:: | ||
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister | ||
from qiskit.circuit.library import CXGate, CZGate | ||
from qiskit.dagcircuit import DAGCircuit | ||
# Build a DAGCircuit | ||
dag = DAGCircuit() | ||
qreg = QuantumRegister(5) | ||
creg = ClassicalRegister(5) | ||
dag.add_qreg(qreg) | ||
dag.add_creg(creg) | ||
dag.apply_operation_back(CXGate(), qreg[[1, 2]], []) | ||
dag.apply_operation_back(CXGate(), qreg[[0, 3]], []) | ||
dag.apply_operation_back(CZGate(), qreg[[1, 4]], []) | ||
dag.apply_operation_back(CZGate(), qreg[[2, 4]], []) | ||
dag.apply_operation_back(CXGate(), qreg[[3, 4]], []) | ||
# Get the causal cone of qubit at index 0 | ||
result = dag.quantum_causal_cone(qreg[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters