PyZX Utilities

graphqomb.zx_util module

PyZX integration utilities.

This module provides:

  • PyZXDiagram: Protocol describing the PyZX graph interface used for import.

  • VertexData: Collected PyZX vertex metadata used during import.

  • EdgeData: Collected PyZX edge metadata used during import.

  • from_pyzx: Convert a graph-like PyZX diagram into a GraphState.

Protocols

class graphqomb.zx_util.PyZXDiagram[source]

Protocol covering the PyZX graph surface used by this module.

__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)

Data Classes

class graphqomb.zx_util.VertexData[source]

Collected PyZX vertex metadata used during import.

vertex_id

Original PyZX vertex id.

Type:

int

vertex_type

PyZX vertex type.

Type:

VertexType

phase

PyZX vertex phase in multiples of pi.

Type:

FractionLike

qubit

PyZX qubit coordinate.

Type:

FloatInt

row

PyZX row coordinate.

Type:

FloatInt

is_ground

Whether the vertex is marked as ground in PyZX.

Type:

bool

__init__(vertex_id, vertex_type, phase, qubit, row, is_ground)
class graphqomb.zx_util.EdgeData[source]

Collected PyZX edge metadata used during import.

source

Smaller endpoint id of the undirected edge.

Type:

int

target

Larger endpoint id of the undirected edge.

Type:

int

edge_type

PyZX edge type.

Type:

EdgeType

__init__(source, target, edge_type)

Functions

graphqomb.zx_util.from_pyzx(diagram, *, recognize_pg=False)[source]

Convert a graph-like PyZX diagram into a graph state.

Parameters:
  • diagram (PyZXDiagram) – Input PyZX diagram in graph-like form.

  • recognize_pg (bool, optional) – Whether to recognize supported lone-Z phase gadgets and import their neighbors as YZ-plane measurements.

Returns:

Imported graph state.

Return type:

GraphState

Raises:

ValueError – If the input diagram is not in strict graph-like form or contains ground vertices.