0

I have a circuit and I want to see the DAG graph at each step of a series of contraction until I get to the unitary matrix of the circuit, I put together some code that should accomplish this, but clearly I made some mistakes as I cannot understand what to put into wires maps, nor if the problem is related to that

Below the code:

# do successive contraction until I have the unitary matrix and display all the intermediate graphs along the way
from qiskit.quantum_info.operators import Operator

def successive_contraction(dag): while len(dag.op_nodes()) > 1: node_block = dag.op_nodes()[:2] # Take the first two nodes as a block op1 = Operator(node_block[0].op) op2 = Operator(node_block[1].op) unitary = op1 ^ op2 # Tensor product of the two operators dag.replace_block_with_op(node_block, unitary, {}) dag_drawer(dag) # Display the intermediate graph

successive_contraction(dag)

0 Answers0