qml.transforms.qcut.tape_to_graph

tape_to_graph(tape: pennylane.tape.tape.QuantumTape)networkx.classes.multidigraph.MultiDiGraph[source]

Converts a quantum tape to a directed multigraph.

Note

This operation is designed for use as part of the circuit cutting workflow. Check out the qml.cut_circuit() transform for more details.

Parameters

tape (QuantumTape) – tape to be converted into a directed multigraph

Returns

a directed multigraph that captures the circuit structure of the input tape

Return type

nx.MultiDiGraph

Example

Consider the following tape:

with qml.tape.QuantumTape() as tape:
    qml.RX(0.4, wires=0)
    qml.RY(0.9, wires=0)
    qml.CNOT(wires=[0, 1])
    qml.expval(qml.PauliZ(1))

Its corresponding circuit graph can be found using

>>> qml.transforms.qcut.tape_to_graph(tape)
<networkx.classes.multidigraph.MultiDiGraph at 0x7fe41cbd7210>