tqec.sketchup.zx_graph.ZXGraph
- class ZXGraph(name: str)[source]
- __init__(name: str) None [source]
An undirected graph representation of a 3D spacetime defect diagram.
Despite the name, the graph is not exactly the ZX-calculus graph as rewrite rules can not be applied to the graph arbitrarily. The graph must correspond to a valid 3D spacetime diagram, which can be realized with the lattice surgery on the 2D patches of surface code. And rewrite rules can only be applied with respect to a valid physical realization of the spacetime diagram.
Note that not all ZX graph admits a valid spacetime diagram representation. And the graph construction does not check the validity constraints.
Methods
__init__
(name)An undirected graph representation of a 3D spacetime defect diagram.
add_edge
(u, v[, has_hadamard])Add an edge to the graph.
add_node
(position, node_type[, raise_if_exist])Add a node to the graph.
add_virtual_node
(position)Add a virtual node to the graph.
add_x_node
(position)Add an X-type node to the graph.
add_z_node
(position)Add a Z-type node to the graph.
draw
(*[, show_correlation_subgraph_index, ...])Draw the 3D graph using matplotlib.
draw_as_correlation_surface_on
(ax[, ...])draw_as_zx_graph_on
(fig, *[, node_size, ...])Draw the 3D graph using matplotlib on the provided figure.
edges_at
(position)Get the edges incident to a node.
find_correlation_subgraphs
()Find the correlation subgraphs of the ZX graph.
get_edge
(u, v)Get the edge by its endpoint positions.
get_node
(position)Get the node by position.
to_block_graph
([name])Construct a block graph from a ZX graph.
Attributes
edges
Return a list of edges in the graph.
isolated_nodes
Get the isolated nodes of the graph.
leaf_nodes
Get the leaf nodes of the graph.
name
The name of the graph.
nodes
Return a list of nodes in the graph.
num_edges
The number of edges in the graph.
num_nodes
The number of nodes in the graph.
nx_graph
The internal networkx graph representation.