cirq.contrib.acquaintance.is_topologically_sorted

Whether a given order of operations is consistent with the DAG.

For example, suppose the (transitive reduction of the) circuit DAG is

 ╭─> Op2 ─╮

Op1 ─┤ ├─> Op4 ╰─> Op3 ─╯

Then [Op1, Op2, Op3, Op4] and Op1, Op3, Op2, Op4 are topologically sorted according to the DAG, and any other ordering of the four operations is not.

Evaluates to False when the set of operations is different from those in the nodes of the DAG, regardless of the ordering.

dag The circuit DAG.
operations The ordered operations.
equals The function to determine equality of operations. Defaults to operator.eq.

Whether or not the operations given are topologically sorted according to the DAG.