iqm.qrisp_iqm.passes.routing.core.graph_processing_tools.reverse_dag#
- iqm.qrisp_iqm.passes.routing.core.graph_processing_tools.reverse_dag(circuit_dag: CircuitDAG) CircuitDAG#
Build a backward instruction DAG by reversing the topological order.
Given a forward CSR instruction DAG whose rows are in topological order, return a new DAG where:
All dependency edges are reversed (transposed).
The row ordering is reversed so that the last forward node becomes backward row 0.
Mathematically the backward adjacency matrix is
B = P · A^T · PwhereAis the forward adjacency matrix andPis the order-reversal permutation. This ensures thatprune_dag()(which slices the firstkrows) peels off gates in backward order.- Parameters:
circuit_dag (CircuitDAG) – CSR instruction DAG.
- Returns:
CSR instruction DAG with reversed topological order and reversed edges.
- Return type: