There is a simple circuit with one CNOT like the following:
- Topology 0 → 1 (directed connection)
- CNOT 1 → 0
Note that CNOT is placed opposite to the connection.
If this is transpiled correctly, it should look like the following circuit.
- HH
- CNOT 0 → 1
- HH
What is the proper Tket transpilation pass(es) required to perform this transpilation?
I wrote the following code but did not get the desired result.
from pytket import Circuit
from pytket.circuit import Node
from pytket.architecture import Architecture
from pytket.placement import place_with_map
from pytket.passes import RoutingPass
nodes = [Node("node" + str(i), i) for i in range(2)]
arch = Architecture([(nodes[1], nodes[0])])
circuit = Circuit(2)
circuit.CX(0, 1) # needs transpilation here
initial_mapping = {circuit.qubits[i]: nodes[i] for i in range(len(nodes))}
place_with_map(circuit, initial_mapping)
transpile
RoutingPass(arch).apply(circuit)