qrisp.QuantumCircuit.get_depth_dic#
- QuantumCircuit.get_depth_dic() dict[Qubit, int][source]#
Returns the depth of each qubit in this QuantumCircuit.
The circuit is transpiled before the depth is evaluated, so that composite gates are fully decomposed into primitive operations. The depth of a qubit is the length of the longest sequential chain of operations acting on it, where every operation contributes a depth of 1.
- Returns:
- dict[Qubit, int]
A dictionary mapping each Qubit to its depth.
See also
QuantumCircuit.depthReturns the overall circuit depth (i.e. the maximum value in this dictionary).
Examples
We create a QuantumCircuit and inspect the per-qubit depth:
>>> from qrisp import QuantumCircuit >>> qc = QuantumCircuit(3) >>> qc.h(0) >>> qc.cx(0, 1) >>> qc.x(1) >>> qc.get_depth_dic() {Qubit(qb_0): 2, Qubit(qb_1): 3, Qubit(qb_2): 0}
qb_0has depth 2 (H followed by CX),qb_1has depth 3 (CX followed by X), andqb_2is idle so its depth is 0.