pytket.zx

class pytket._tket.zx.CliffordGen

Specialisation of ZXGen for arbitrary-arity, symmetric Clifford generators with a single boolean parameter.

__init__(self: pytket._tket.zx.CliffordGen, zxtype: pytket._tket.zx.ZXType, param: bool = False, qtype: pytket._tket.zx.QuantumType = <QuantumType.Quantum: 0>) None

Construct from a ZX type, parameter and quantum type.

property param

The parameter of the generator.

class pytket._tket.zx.DirectedGen

Specialisation of ZXGen for asymmetric ZX generators which can be doubled to form a Quantum variant. Asymmetric effects handled by ports to distinguish operands.

__init__(self: pytket._tket.zx.DirectedGen, zxtype: pytket._tket.zx.ZXType, qtype: pytket._tket.zx.QuantumType) None

Construct from a ZX type and quantum type.

property n_ports

The number of ports on the generator.

property signature

A list of QuantumType s indicating the expected QuantumType at each port.

class pytket._tket.zx.Flow

Data structure for describing the Flow in a given MBQC-form ZXDiagram object. Constructors are identification methods for different classes of Flow.

__init__(*args, **kwargs)
c(self: pytket._tket.zx.Flow, v: pytket._tket.zx.ZXVert) list[pytket._tket.zx.ZXVert]

The correction set for the given ZXVert.

d(self: pytket._tket.zx.Flow, arg0: pytket._tket.zx.ZXVert) int

The depth of the given ZXVert from the outputs in the ordering of the flow, e.g. an output vertex will have depth 0, the last measured vertex has depth 1.

focus(self: pytket._tket.zx.Flow, diag: pytket._tket.zx.ZXDiagram) None

Focusses a flow.

static identify_causal_flow(diag: pytket._tket.zx.ZXDiagram) pytket._tket.zx.Flow

Attempts to identify a causal flow for a diagram.

static identify_focussed_sets(diag: pytket._tket.zx.ZXDiagram) list[list[pytket._tket.zx.ZXVert]]

Attempts to identify the sets of vertices which are focussed over all vertices, i.e. the remaining stabilisers not generated by correction sets within a flow.

static identify_pauli_flow(diag: pytket._tket.zx.ZXDiagram) pytket._tket.zx.Flow

Attempts to identify a Pauli flow for a diagram.

odd(self: pytket._tket.zx.Flow, v: pytket._tket.zx.ZXVert, diag: pytket._tket.zx.ZXDiagram) list[pytket._tket.zx.ZXVert]

The odd neighbourhood of the correction set for the given ZXVert.

property cmap

The map from a vertex to its correction set

property dmap

The map from a vertex to its depth

class pytket._tket.zx.PhasedGen

Specialisation of ZXGen for arbitrary-arity, symmetric generators with a single continuous parameter.

__init__(self: pytket._tket.zx.PhasedGen, zxtype: pytket._tket.zx.ZXType, param: typing.Union[sympy.Expr, float] = 0.0, qtype: pytket._tket.zx.QuantumType = <QuantumType.Quantum: 0>) None

Construct from a ZX type, parameter and quantum type.

property param

The parameter of the generator.

class pytket._tket.zx.QuantumType

Enum for specifying quantumness of vertices, ports, and wires in ZXDiagram s for mixed quantum-classical processes.

Members:

Quantum : Quantum components of diagrams, represented in the framework of completely-positive maps by two parallel copies of a system related by conjugation.

Classical : Classical components of diagrams, represented in the framework of completely-positive maps by a single self-conjugate system.

__init__(self: pytket._tket.zx.QuantumType, value: int) None
property name
class pytket._tket.zx.Rewrite

An in-place transformation of a ZXDiagram.

__init__(*args, **kwargs)
apply(self: pytket._tket.zx.Rewrite, diag: pytket._tket.zx.ZXDiagram) bool

Performs the transformation on the diagram in place.

Parameters:

diag – The diagram to be transformed.

Returns:

True if any changes were made, else False.

static basic_wires() pytket._tket.zx.Rewrite

Replaces every Hadamard wire by an explicit Hbox node.

static decompose_boxes() pytket._tket.zx.Rewrite

Replaces every ZXBox by its internal diagram recursively until no ZXBox es remain.

static extend_at_boundary_paulis() pytket._tket.zx.Rewrite

Identifies adjacent Pauli spiders where one is adjacent to a boundary. This rule applies I/O extensions to push the match into the interior from which it can be handled by remove_interior_paulis().

static extend_for_PX_outputs() pytket._tket.zx.Rewrite

Identifies output vertices in MBQC form that are given a measurement basis (i.e. are not PX(0)). This rule applies I/O extensions to make the phased qubits non-outputs. This is required before flow identification can be run.

static gadgetise_interior_paulis() pytket._tket.zx.Rewrite

Identifies interior Paulis (spiders where the phase is an integer multiple of pi) with all neighbours having non-Pauli phase and degree > 1. Pivots about an incident edge to yield a gadget node.

static internalise_gadgets() pytket._tket.zx.Rewrite

Identifies Degree-1 XY vertices next to a PX vertex, e.g. as the result of rebasing a phase gadget. Replaces matches by a single YZ vertex.

static io_extension() pytket._tket.zx.Rewrite

Guarantees that the edge on each boundary vertex is Basic. If a boundary has a Hadamard, then we add a ZSpider identity as in I/O extensions in MBQC.

static merge_gadgets() pytket._tket.zx.Rewrite

Identifies pairs of phase gadgets over the same sets of qubits and merges them.

static parallel_h_removal() pytket._tket.zx.Rewrite

Remove parallel edges between ZX spiders (a.k.a. the Hopf rule). Matches either pairs of H edges between spiders of the same colour or Basic edges between spiders of different colour. This applies to Quantum edges between a pair of Classical spiders.

static rebase_to_mbqc() pytket._tket.zx.Rewrite

Expands every generator into MBQC vertices.

static rebase_to_zx() pytket._tket.zx.Rewrite

Expands every generator into ZSpiders, XSpiders, and a combination of Basic and Hadamard edges.

static red_to_green() pytket._tket.zx.Rewrite

Converts all red spiders (XSpider) to green (ZSpider) with Hadamards around them. The Hadamards are applied by flipping the wire type of incident edges between Basic and H.

static reduce_graphlike_form() pytket._tket.zx.Rewrite

Given a diagram in graphlike form, applies local complementations and pivoting to remove as many interior Clifford-angled vertices as possible. The only remaining Clifford-angled vertices will be either the axis of a phase-gadget or near a boundary.

static remove_interior_cliffords() pytket._tket.zx.Rewrite

Removes interior proper Cliffords (spiders where the phase is an odd multiple of pi/2 radians or 0.5 half-turns). Performs local complementation about the vertex and removes it.

static remove_interior_paulis() pytket._tket.zx.Rewrite

Removes adjacent interior Paulis (spiders where the phase is an integer multiple of pi radians or integer half-turns). Pivots about the edge connecting the vertices and removes them.

static repeat(rewrite: pytket._tket.zx.Rewrite) pytket._tket.zx.Rewrite

Applies a given Rewrite repeatedly to a diagram until no further changes are made (i.e. it no longer returns True). apply will return True if at least one run returned True.

Parameters:

rewrite – The Rewrite to be applied repeatedly.

Returns:

A new Rewrite representing the iteration.

static self_loop_removal() pytket._tket.zx.Rewrite

Removes both H and Basic self loop edges around ZX spiders. Basic edges can simply be removed. Removing H loops introduces an extra pi phase on the spider.

static separate_boundaries() pytket._tket.zx.Rewrite

Guarantees that each boundary vertex is adjacent to a unique ZSpider. This adds identity chains when two boundaries are either directly connected or are adjacent to the same spider.

static sequence(sequence: Sequence[pytket._tket.zx.Rewrite]) pytket._tket.zx.Rewrite

Composes a list of Rewrite s together in sequence. The apply method will return True if ANY of the individual Rewrites returned True.

Parameters:

sequence – The list of Rewrite s to be composed.

Returns:

The combined Rewrite.

static spider_fusion() pytket._tket.zx.Rewrite

Merges two adjacent ZX spiders (XSpider, ZSpider) of the same colour connected by a Basic wire into a single spider. Also merges two adjacent spiders of different colour connected by a H edge.

static to_MBQC_diag() pytket._tket.zx.Rewrite

Given a diagram in graphlike form, will rebase to MBQC generators, ensure that output qubits are PX(0) (i.e. they match unmeasured qubits) and degree-1 vertices are absorbed into a PX neighbour, i.e. reducing phase-gadgets to single vertices in a different measurement plane.

static to_graphlike_form() pytket._tket.zx.Rewrite

Given a diagram with ZX generators, yields a diagram with only ZSpiders, connected by at most one Hadamard edge, with boundaries connected via Basic edges.

class pytket._tket.zx.ZXBox

Specialisation of ZXGen for encapsulations of some other ZX diagrams. In general, arbitrary diagrams may be asymmetric tensors with both Quantum and Classical boundaries, so ports are used to distinguish each boundary.

__init__(self: pytket._tket.zx.ZXBox, zxdiag: pytket._tket.zx.ZXDiagram) None

Construct from a ZX diagram.

property diagram

The internal diagram represented by the box.

property n_ports

The number of ports on the generator.

property signature

A list of QuantumType s indicating the expected QuantumType at each port.

class pytket._tket.zx.ZXDiagram

Undirected graphs for mixed process ZX diagrams. The boundary is an ordered list which may mix inputs, outputs, and “open” vertices (not specified to be inputs or outputs). Directed vertices (e.g. Boxes, Triangles, etc.) have numbered ports to distinguish different incident edges. The content of each vertex is given by a ZXGen generator, describing the ZXType (e.g. XSpider, Input, Triangle), the QuantumType for single/doubled versions of typical generators, and any parameters such as phase. Wires are undirected and have a ZXWireType (e.g. Basic, Hadamard) and QuantumType (a single wire or a doubled pair for a quantum system).

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pytket._tket.zx.ZXDiagram) -> None

Constructs an empty ZX diagram.

  1. __init__(self: pytket._tket.zx.ZXDiagram, inputs: int, outputs: int, classical_inputs: int, classical_outputs: int) -> None

Constructs an empty ZX diagram with a given number of unconnected boundary vertices.

Parameters:
  • in – Number of quantum inputs.

  • out – Number of quantum outputs.

  • classical_in – Number of classical inputs.

  • classical_out – Number of classical outputs.

  1. __init__(self: pytket._tket.zx.ZXDiagram, other: pytket._tket.zx.ZXDiagram) -> None

Constructs a copy of an existing ZX diagram.

Parameters:

other – ZX diagram to copy.

add_vertex(*args, **kwargs)

Overloaded function.

  1. add_vertex(self: pytket._tket.zx.ZXDiagram, gen: pytket._tket.zx.ZXGen) -> pytket._tket.zx.ZXVert

Adds a new vertex to the diagram for an arbitrary ZXGen.

Parameters:

gen – The ZXGen for the new vertex.

Returns:

The handle to the new vertex.

  1. add_vertex(self: pytket._tket.zx.ZXDiagram, type: pytket._tket.zx.ZXType, qtype: pytket._tket.zx.QuantumType = <QuantumType.Quantum: 0>) -> pytket._tket.zx.ZXVert

Adds a new vertex to the diagram for an unparameterised, doubleable generator type.

Parameters:
  • type – The ZXType for the new vertex.

  • qtype – The QuantumType for the new vertex. Defaults to Quantum.

Returns:

The handle to the new vertex.

  1. add_vertex(self: pytket._tket.zx.ZXDiagram, type: pytket._tket.zx.ZXType, param: bool, qtype: pytket._tket.zx.QuantumType = <QuantumType.Quantum: 0>) -> pytket._tket.zx.ZXVert

Adds a new vertex to the diagram for a Boolean-parameterised, doubleable generator type.

Parameters:
  • type – The ZXType for the new vertex.

  • param – The parameter for the new vertex.

  • qtype – The QuantumType for the new vertex. Defaults to Quantum.

Returns:

The handle to the new vertex.

  1. add_vertex(self: pytket._tket.zx.ZXDiagram, type: pytket._tket.zx.ZXType, param: typing.Union[sympy.Expr, float], qtype: pytket._tket.zx.QuantumType = <QuantumType.Quantum: 0>) -> pytket._tket.zx.ZXVert

Adds a new vertex to the diagram for a parameterised, doubleable generator type.

Parameters:
  • type – The ZXType for the new vertex.

  • param – The parameter for the new vertex.

  • qtype – The QuantumType for the new vertex. Defaults to Quantum.

Returns:

The handle to the new vertex.

add_wire(self: pytket._tket.zx.ZXDiagram, u: pytket._tket.zx.ZXVert, v: pytket._tket.zx.ZXVert, type: pytket._tket.zx.ZXWireType = <ZXWireType.Basic: 0>, qtype: pytket._tket.zx.QuantumType = <QuantumType.Quantum: 0>, u_port: Optional[int] = None, v_port: Optional[int] = None) pytket._tket.zx.ZXWire

Adds a new wire to the diagram between the given vertices.

Parameters:
  • u – Handle to the first vertex.

  • v – Handle to the other vertex.

  • typeZXWireType for the wire. Defaults to Basic.

  • qtypeQuantumType for the wire. Defaults to Quantum.

  • u_port – Port on vertex u to connect to. Defaults to None.

  • v_port – Port on vertex v to connect to. Defaults to None.

Returns:

The handle to the new wire.

add_zxbox(self: pytket._tket.zx.ZXDiagram, inner: pytket._tket.zx.ZXDiagram) pytket._tket.zx.ZXVert

Adds a new vertex to the diagram for a box with some inner implementation.

Parameters:

inner – The ZXDiagram to internalise inside the box. The current state is copied by value.

Returns:

The handle to the new vertex.

adj_wires(self: pytket._tket.zx.ZXDiagram, v: pytket._tket.zx.ZXVert) list[pytket._tket.zx.ZXWire]

Given a vertex, returns a list of all incident wires. Self-loops will only appear once in the list. The order of the wire list may not be semantically relevant.

check_validity(self: pytket._tket.zx.ZXDiagram) None

Performs a check for the internal validity of the ZXDiagram and raises an exception if it is invalid. - Inputs/Outputs must have degree 1 and all exist within the boundary. - Undirected vertices (those without ports) have no ports on incident edges. - Directed vertices (those with ports) have exactly one incident edge at each port. - QuantumType of wires are compatible with the QuantumType s of the ports they attach to.

count_vertices(self: pytket._tket.zx.ZXDiagram, type: pytket._tket.zx.ZXType) int

Counts the number of vertices of a given ZXType in the diagram.

count_wires(self: pytket._tket.zx.ZXDiagram, type: pytket._tket.zx.ZXWireType) int

Counts the number of wired of a given ZXWireType in the diagram.

degree(self: pytket._tket.zx.ZXDiagram, v: pytket._tket.zx.ZXVert) int

Returns the degree of the given vertex.

free_symbols(self: pytket._tket.zx.ZXDiagram) set[sympy.Symbol]

Returns the set of symbolic parameters in the diagram.

get_boundary(self: pytket._tket.zx.ZXDiagram, type: pytket._tket.zx.ZXType | None = None, qtype: pytket._tket.zx.QuantumType | None = None) list[pytket._tket.zx.ZXVert]

Returns handles to boundary vertices in order. Optionally filter by type of boundary vertex.

Parameters:
  • typeZXType to filter by, from {ZXType.Input(), ZXType.Output(), ZXType.Open(), None}. Defaults to None.

  • qtypeQuantumType to filter by, from {QuantumType.Quantum(), QuantumType.Classical(), None}. Defaults to None.

get_name(self: pytket._tket.zx.ZXDiagram, v: pytket._tket.zx.ZXVert) str

Returns the readable string description of a given vertex

get_qtype(self: pytket._tket.zx.ZXDiagram, v: pytket._tket.zx.ZXVert) pytket._tket.zx.QuantumType | None

Returns the QuantumType of the given vertex if defined, None otherwise.

get_vertex_ZXGen(self: pytket._tket.zx.ZXDiagram, v: pytket._tket.zx.ZXVert) pytket._tket.zx.ZXGen

Returns the content of a given vertex as a ZXGen.

get_wire_ends(self: pytket._tket.zx.ZXDiagram, w: pytket._tket.zx.ZXWire) tuple[tuple[pytket._tket.zx.ZXVert, int | None], tuple[pytket._tket.zx.ZXVert, int | None]]

Returns a tuple ((vertex0, port0), (vertex1, port1)) describing the two ends of the wire.

get_wire_qtype(self: pytket._tket.zx.ZXDiagram, w: pytket._tket.zx.ZXWire) pytket._tket.zx.QuantumType

Returns the QuantumType of the given wire.

get_wire_type(self: pytket._tket.zx.ZXDiagram, w: pytket._tket.zx.ZXWire) pytket._tket.zx.ZXWireType

Returns the ZXWireType of the given wire.

get_zxtype(self: pytket._tket.zx.ZXDiagram, v: pytket._tket.zx.ZXVert) pytket._tket.zx.ZXType

Returns the ZXType of the given vertex.

is_symbolic(self: pytket._tket.zx.ZXDiagram) bool

Returns True if the diagram contains any free symbols, False otherwise.

multiply_scalar(self: pytket._tket.zx.ZXDiagram, scalar: Union[sympy.Expr, float]) None

Multiplies the global scalar by a numerical (possibly symbolic) constant.

neighbours(self: pytket._tket.zx.ZXDiagram, v: pytket._tket.zx.ZXVert) list[pytket._tket.zx.ZXVert]

Given a vertex, returns a list of all vertices neighbouring it. Each neighbour will only appear in the list once regardless of how many shared edges there are. The order of the neighbour list may not be semantically relevant.

other_end(self: pytket._tket.zx.ZXDiagram, w: pytket._tket.zx.ZXWire, v: pytket._tket.zx.ZXVert) pytket._tket.zx.ZXVert

Given a wire and a vertex at one end of the wire, gives the vertex at the other end of the wire. This can be used to traverse the undirected edges of the graph.

remove_vertex(self: pytket._tket.zx.ZXDiagram, v: pytket._tket.zx.ZXVert) None

Removes the given vertex and all incident wires from the diagram. If the vertex is in the boundary, it is removed from the boundary.

remove_wire(self: pytket._tket.zx.ZXDiagram, w: pytket._tket.zx.ZXWire) None

Removes the given wire from the diagram.

set_vertex_ZXGen(self: pytket._tket.zx.ZXDiagram, v: pytket._tket.zx.ZXVert, gen: pytket._tket.zx.ZXGen) None

Updates the content of a given vertex to a particular ZXGen.

set_wire_qtype(self: pytket._tket.zx.ZXDiagram, w: pytket._tket.zx.ZXWire, qtype: pytket._tket.zx.QuantumType) None

Updates the QuantumType of the given wire.

set_wire_type(self: pytket._tket.zx.ZXDiagram, w: pytket._tket.zx.ZXWire, type: pytket._tket.zx.ZXWireType) None

Updates the ZXWireType of the given wire.

symbol_substitution(*args, **kwargs)

Overloaded function.

  1. symbol_substitution(self: pytket._tket.zx.ZXDiagram, symbol_map: dict[sympy.Symbol, typing.Union[sympy.Expr, float]]) -> None

In-place substitution for symbolic expressions; iterated through each parameterised vertex and performs the substitution. This will not affect any symbols captured within boxed operations.

Parameters:

symbol_map – A map from SymPy symbols to SymPy expressions.

  1. symbol_substitution(self: pytket._tket.zx.ZXDiagram, symbol_map: dict[sympy.Symbol, float]) -> None

In-place substitution for symbolic expressions; iterated through each parameterised vertex and performs the substitution. This will not affect any symbols captured within boxed operations.

Parameters:

symbol_map – A map from SymPy symbols to floating-point values.

to_circuit(self: pytket._tket.zx.ZXDiagram) tuple[pytket._tket.circuit.Circuit, dict[pytket._tket.zx.ZXVert, pytket._tket.unit_id.UnitID]]

Extracts a unitary diagram in MBQC form as a Circuit following the routine by Backens et al. (“There and back again: A circuit extraction tale”).

Returns:

A pair of the generated Circuit, and a map from each boundary vertex in the ZXDiagram to its corresponding UnitID in the Circuit.

to_doubled_diagram(self: pytket._tket.zx.ZXDiagram) pytket._tket.zx.ZXDiagram
  • classical boundaries only have the unconjugated version

to_graphviz_str(self: pytket._tket.zx.ZXDiagram) str

Returns a graphviz source string

wire_at_port(self: pytket._tket.zx.ZXDiagram, v: pytket._tket.zx.ZXVert, port: int) pytket._tket.zx.ZXWire

Given a vertex, returns the unique wire at the given port number. Raises an exception if multiple wires are found at the given port.

wire_between(self: pytket._tket.zx.ZXDiagram, u: pytket._tket.zx.ZXVert, v: pytket._tket.zx.ZXVert) pytket._tket.zx.ZXWire | None

Given two vertices, returns either an arbitrary edge between them if one exists or None if they are not adjacent.

wires_between(self: pytket._tket.zx.ZXDiagram, u: pytket._tket.zx.ZXVert, v: pytket._tket.zx.ZXVert) list[pytket._tket.zx.ZXWire]

Given two vertices, returns a list of all wires between them. The order of the wire list may not be semantically relevant.

property n_vertices

Counts the number of vertices in the diagram. Includes boundary vertices and disconnected vertices.

property n_wires

Counts the number of edges in the diagram.

property scalar

Returns the global scalar stored numerically. This may be a symbolic expression.

property vertices

Returns a list of handles to all vertices in the diagram. The order of vertices may not be semantically relevant.

property wires

Returns a list of handles to all wires in the diagram. The order of wires may not be semantically relevant.

class pytket._tket.zx.ZXGen

Encapsulates the information about the generator depicted by a given vertex in a ZXDiagram.

__init__(*args, **kwargs)
static create(*args, **kwargs)

Overloaded function.

  1. create(type: pytket._tket.zx.ZXType, qtype: pytket._tket.zx.QuantumType = <QuantumType.Quantum: 0>) -> pytket._tket.zx.ZXGen

Create a boundary type generator.

  1. create(type: pytket._tket.zx.ZXType, param: typing.Union[sympy.Expr, float], qtype: pytket._tket.zx.QuantumType = <QuantumType.Quantum: 0>) -> pytket._tket.zx.ZXGen

Create a boundary type generator.

property qtype

The QuantumType of the generator (if applicable).

property type

The type of generator.

class pytket._tket.zx.ZXType

Enum for available types of generators in ZXDiagram s.

Members:

Input : An input boundary vertex. Can either be Quantum or Classical. Must have degree 1. No ports.

Output : An output boundary vertex. Can either be Quantum or Classical. Must have degree 1. No ports.

Open : A boundary vertex that has not yet been specified as input or output. Can either be Quantum or Classical. Must have degree 1. No ports.

ZSpider : A Z (green) spider. Parameterised by a single phase in half-turns. Can either be Quantum or Classical - Quantum spiders can only have Quantum wires, Quantum wires on Classical spiders act as two wires. Can have arbitrary degree. No ports.

XSpider : An X (red) spider. Parameterised by a single phase in half-turns. Can either be Quantum or Classical - Quantum spiders can only have Quantum wires, Quantum wires on Classical spiders act as two wires. Can have arbitrary degree. No ports.

Hbox : A Hadamard box for ZH diagrams. Parameterised by a single complex value. Can either be Quantum or Classical - Quantum spiders can only have Quantum wires, Quantum wires on Classical spiders act as two wires. Can have arbitrary degree. No ports.

XY : A (postselected) XY qubit in MBQC. Corresponds to a Z spider with negative phase.

XZ : A (postselected) XZ qubit in MBQC. Corresponds to a 0.5-phase (n+1)-ary Z spider connected to a phaseful 1-ary X spider.

YZ : A (postselected) YZ qubit in MBQC. Corresponds to a 0-phase (n+1)-ary Z spider connected to a phaseful 1-ary X spider.

PX : A (postselected) Pauli X qubit in MBQC. Corresponds to a Z spider with phase either 0 (param=False) or 1 (param=True).

PY : A (postselected) Pauli Y qubit in MBQC. Corresponds to a Z spider with phase either -0.5 (param=False) or +0.5 (param=True).

PZ : A (postselected) Pauli Z qubit in MBQC. Corresponds to a 0-phase (n+1)-ary Z spider connected to a 1-ary X spider with phase either 0 (param=False) or 1 (param=True).

Triangle : A Triangle operator, [[1, 1], [0, 1]]. Can either be Quantum or Classical, only admitting wires of the same type. Port 0 for the base of the triangle (input), port 1 for the tip (output).

ZXBox : A box encapsulating another ZXDiagram. Inherits ports from the boundary of the internal diagram, with port numbers matching the boundary order and QuantumType admitted at each port matching that of the boundary vertex.

__init__(self: pytket._tket.zx.ZXType, value: int) None
property name
class pytket._tket.zx.ZXVert

A handle to a vertex in a ZXDiagram. Each instance is specific to a given ZXDiagram instance and can be invalidated by rewrites. Exceptions or errors may occur if calling functions on a ZXVert that is not present in the given ZXDiagram.

__init__(*args, **kwargs)
class pytket._tket.zx.ZXWire

A handle to a wire in a ZXDiagram. Each instance is specific to a given ZXDiagram instance and can be invalidated by rewrites. Exceptions or errors may occur if calling functions on a ZXWire that is not present in the given ZXDiagram.

__init__(*args, **kwargs)
class pytket._tket.zx.ZXWireType

Enum for available types of wires in ZXDiagram s.

Members:

Basic : A basic identity wire.

H : A Hadamard edge.

__init__(self: pytket._tket.zx.ZXWireType, value: int) None
property name
pytket._tket.zx.circuit_to_zx(arg0: pytket._tket.circuit.Circuit) tuple[pytket._tket.zx.ZXDiagram, dict[pytket._tket.unit_id.UnitID, tuple[pytket._tket.zx.ZXVert, pytket._tket.zx.ZXVert]]]

Construct a ZX diagram from a circuit. Return the ZX diagram and a map Between the ZX boundary vertices and the resource UIDs of the circuit.