DAGDependency¶

class DAGDependency[Quellcode]

Bases: object

Object to represent a quantum circuit as a directed acyclic graph via operation dependencies (i.e. lack of commutation).

The nodes in the graph are operations represented by quantum gates. The edges correspond to non-commutation between two operations (i.e. a dependency). A directed edge from node A to node B means that operation A does not commute with operation B. The object’s methods allow circuits to be constructed.

The nodes in the graph have the following attributes: ‚operation‘, ‚successors‘, ‚predecessors‘.

Example:

Bell circuit with no measurement.

      ┌───┐
qr_0: ┤ H ├──■──
└───┘┌─┴─┐
qr_1: ─────┤ X ├
└───┘


The dependency DAG for the above circuit is represented by two nodes. The first one corresponds to Hadamard gate, the second one to the CNOT gate as the gates do not commute there is an edge between the two nodes.

Reference:

[1] Iten, R., Moyard, R., Metger, T., Sutter, D. and Woerner, S., 2020. Exact and practical pattern matching for quantum circuit optimization. arXiv:1909.05270

Create an empty DAGDependency.

Methods

 add_clbits Add individual clbit wires. add_creg Add clbits in a classical register. add_op_node Add a DAGDepNode to the graph and update the edges. add_qreg Add qubits in a quantum register. add_qubits Add individual qubit wires. copy Function to copy a DAGDependency object. depth Return the circuit depth. direct_predecessors Direct predecessors id of a given node as sorted list. direct_successors Direct successors id of a given node as sorted list. draw Draws the DAGDependency graph. get_all_edges Enumeration of all edges. get_edges Edge enumeration between two nodes through method get_all_edge_data. get_in_edges Enumeration of all incoming edges for a given node. get_node param node_id label of considered node. get_nodes returns iterator over all the nodes. get_out_edges Enumeration of all outgoing edges for a given node. predecessors Predecessors id of a given node as sorted list. size Returns the number of gates in the circuit successors Successors id of a given node as sorted list. to_networkx Returns a copy of the DAGDependency in networkx format. to_retworkx Returns the DAGDependency in retworkx format. topological_nodes Yield nodes in topological order.

Attributes

calibrations

Return calibration dictionary.

The custom pulse definition of a given gate is of the form

{‚gate_name‘: {(qubits, params): schedule}}

global_phase

Return the global phase of the circuit.