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’.
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.
 Iten, R., Sutter, D. and Woerner, S., 2019. Efficient template matching in quantum circuits. arXiv:1909.05270
Create an empty DAGDependency.
Add clbits in a classical register.
DAGDependency.add_op_node(operation, qargs, …)
Add a DAGDepNode to the graph and update the edges.
Add qubits in a quantum register.
Function to copy a DAGDependency object.
Return the circuit depth.
Direct predecessors id of a given node as sorted list.
Direct successors id of a given node as sorted list.
DAGDependency.draw([scale, filename, style])
Draws the DAGDependency graph.
Enumaration of all edges.
Edge enumeration between two nodes through method get_all_edge_data.
Enumeration of all incoming edges for a given node.
- param node_id
label of considered node.
iterator over all the nodes.
Enumeration of all outgoing edges for a given node.
Predecessors id of a given node as sorted list.
Returns the number of gates in the circuit
Successors id of a given node as sorted list.
Returns a copy of the DAGDependency in networkx format.
Returns the DAGDependency in retworkx format.
Yield nodes in topological order.