cirq.CircuitDag

class cirq.CircuitDag(can_reorder: Callable[[cirq.Operation, cirq.Operation], bool] = <function _disjoint_qubits>, incoming_graph_data: Any = None, device: cirq.devices.device.Device = cirq.UNCONSTRAINED_DEVICE)[source]

A representation of a Circuit as a directed acyclic graph.

Nodes of the graph are instances of Unique containing each operation of a
circuit.
Edges of the graph are tuples of nodes. Each edge specifies a required
application order between two operations. The first must be applied before
the second.

The graph is maximalist (transitive completion).

__init__(can_reorder: Callable[[cirq.Operation, cirq.Operation], bool] = <function _disjoint_qubits>, incoming_graph_data: Any = None, device: cirq.devices.device.Device = cirq.UNCONSTRAINED_DEVICE) → None[source]

Initializes a CircuitDag.

Parameters
  • can_reorder

    A predicate that determines if two operations may be reordered. Graph edges are created for pairs of operations where this returns False.

    The default predicate allows reordering only when the operations don’t share common qubits.

  • incoming_graph_data – Data in initialize the graph. This can be any value supported by networkx.DiGraph() e.g. an edge list or another graph.

  • device – Hardware that the circuit should be able to run on.