DAGCircuit

class DAGCircuit[source]

Quantum circuit as a directed acyclic graph.

There are 3 types of nodes in the graph: inputs, outputs, and operations. The nodes are connected by directed edges that correspond to qubits and bits.

Create an empty circuit.

Attributes

DAGCircuit.calibrations

Return calibration dictionary.

DAGCircuit.clbits

Return a list of classical bits (as a list of Clbit instances).

DAGCircuit.global_phase

Return the global phase of the circuit.

DAGCircuit.node_counter

Returns the number of nodes in the dag.

DAGCircuit.qubits

Return a list of qubits (as a list of Qubit instances).

DAGCircuit.wires

Return a list of the wires in order.

Methods

DAGCircuit.add_creg(creg)

Add all wires in a classical register.

DAGCircuit.add_qreg(qreg)

Add all wires in a quantum register.

DAGCircuit.ancestors(node)

Returns set of the ancestors of a node as DAGNodes.

DAGCircuit.apply_operation_back(op[, qargs, …])

Apply an operation to the output of the circuit.

DAGCircuit.apply_operation_front(op, qargs, …)

Apply an operation to the input of the circuit.

DAGCircuit.bfs_successors(node)

Returns an iterator of tuples of (DAGNode, [DAGNodes]) where the DAGNode is the current node and [DAGNode] is its successors in BFS order.

DAGCircuit.collect_runs(namelist)

Return a set of non-conditional runs of “op” nodes with the given names.

DAGCircuit.compose(other[, edge_map, …])

Compose the other circuit onto the output of this circuit.

DAGCircuit.compose_back(input_circuit[, …])

DEPRECATED: use DAGCircuit.compose() instead.

DAGCircuit.count_ops()

Count the occurrences of operation names.

DAGCircuit.count_ops_longest_path()

Count the occurrences of operation names on the longest path.

DAGCircuit.depth()

Return the circuit depth.

DAGCircuit.descendants(node)

Returns set of the descendants of a node as DAGNodes.

DAGCircuit.draw([scale, filename, style])

Draws the dag circuit.

DAGCircuit.edges([nodes])

Iterator for edge values and source and dest node

DAGCircuit.extend_back(dag[, edge_map])

DEPRECATED: Add dag at the end of self, using edge_map.

DAGCircuit.from_networkx(graph)

Take a networkx MultiDigraph and create a new DAGCircuit.

DAGCircuit.front_layer()

Return a list of op nodes in the first layer of this dag.

DAGCircuit.gate_nodes()

Get the list of gate nodes in the dag.

DAGCircuit.has_calibration_for(node)

Return True if the dag has a calibration defined for the node operation.

DAGCircuit.idle_wires([ignore])

Return idle wires.

DAGCircuit.layers()

Yield a shallow view on a layer of this DAGCircuit for all d layers of this circuit.

DAGCircuit.longest_path()

Returns the longest path in the dag as a list of DAGNodes.

DAGCircuit.multi_qubit_ops()

Get list of 3+ qubit operations.

DAGCircuit.multigraph_layers()

Yield layers of the multigraph.

DAGCircuit.named_nodes(*names)

Get the set of “op” nodes with the given name.

DAGCircuit.node(node_id)

Get the node in the dag.

DAGCircuit.nodes()

Iterator for node values.

DAGCircuit.nodes_on_wire(wire[, only_ops])

Iterator for nodes that affect a given wire.

DAGCircuit.num_clbits()

Return the total number of classical bits used by the circuit.

DAGCircuit.num_qubits()

Return the total number of qubits used by the circuit.

DAGCircuit.num_tensor_factors()

Compute how many components the circuit can decompose into.

DAGCircuit.op_nodes([op, include_directives])

Get the list of “op” nodes in the dag.

DAGCircuit.predecessors(node)

Returns iterator of the predecessors of a node as DAGNodes.

DAGCircuit.properties()

Return a dictionary of circuit properties.

DAGCircuit.quantum_predecessors(node)

Returns iterator of the predecessors of a node that are connected by a quantum edge as DAGNodes.

DAGCircuit.quantum_successors(node)

Returns iterator of the successors of a node that are connected by a quantum edge as DAGNodes.

DAGCircuit.remove_all_ops_named(opname)

Remove all operation nodes with the given name.

DAGCircuit.remove_ancestors_of(node)

Remove all of the ancestor operation nodes of node.

DAGCircuit.remove_descendants_of(node)

Remove all of the descendant operation nodes of node.

DAGCircuit.remove_nonancestors_of(node)

Remove all of the non-ancestors operation nodes of node.

DAGCircuit.remove_nondescendants_of(node)

Remove all of the non-descendants operation nodes of node.

DAGCircuit.remove_op_node(node)

Remove an operation node n.

DAGCircuit.reverse_ops()

Reverse the operations in the self circuit.

DAGCircuit.serial_layers()

Yield a layer for all gates of this circuit.

DAGCircuit.size()

Return the number of operations.

DAGCircuit.substitute_node(node, op[, inplace])

Replace a DAGNode with a single instruction.

DAGCircuit.substitute_node_with_dag(node, …)

Replace one node with dag.

DAGCircuit.successors(node)

Returns iterator of the successors of a node as DAGNodes.

DAGCircuit.threeQ_or_more_gates()

Get list of 3-or-more-qubit gates: (id, data).

DAGCircuit.to_networkx()

Returns a copy of the DAGCircuit in networkx format.

DAGCircuit.topological_nodes()

Yield nodes in topological order.

DAGCircuit.topological_op_nodes()

Yield op nodes in topological order.

DAGCircuit.twoQ_gates()

Get list of 2-qubit gates.

DAGCircuit.two_qubit_ops()

Get list of 2 qubit operations.

DAGCircuit.width()

Return the total number of qubits + clbits used by the circuit.