tqec.computation.zx_graph.ZXGraph#
- class ZXGraph(name: str = '')[source]#
ZX graph representation of a logical computation.
The ZX graph is in the form of a ZX-calculus graph and the representation is based on the correspondence between the ZX- calculus and the lattice surgery.
- __init__(name: str = '') None #
Methods
__init__
([name])add_edge
(u, v[, has_hadamard])Add an edge to the graph.
add_node
(node[, check_conflict])Add a node to the graph.
draw
()Draw the graph using matplotlib.
edges_at
(position)Get the edges incident to a position.
fill_ports
(fill)Fill the ports at specified position with a node with the given kind.
find_correration_surfaces
()Find the correlation surfaces in the ZX graph.
get_degree
(position)Get the degree of a node in the graph, i.e. the number of edges incident to it.
get_edge
(pos1, pos2)Get the edge by its endpoint positions.
has_edge_between
(pos1, pos2)Check if there is an edge between two positions.
raise_if_cannot_be_valid_computation
()Check the validity of the graph to represent a computation.
to_block_graph
([name])Construct a block graph from a ZX graph.
with_zx_flipped
([name])Get a new ZX graph with the node kind flipped.
Attributes
edges
Return a list of edges in the graph.
leaf_nodes
Get the leaf nodes of the graph, i.e. the nodes with degree 1.
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.
num_ports
The number of ports in the graph.
ports
Get a mapping from the labels of the ports in the graph to their positions.