tqec.computation.block_graph.BlockGraph#

class BlockGraph(name: str = '')[source]#

An undirected graph representation of a logical computation.

The block graph specifies the explicit block structures of the spacetime diagram, including the layout of the code patches, the boundary types and the connectivity of the patches across the spacetime. The block graph can be compiled and used to generate the concrete circuits that implement the logical computation.

The nodes in the graph are the cubes that represent a unit of code patch in the spacetime. The edges in the graph are the pipes that connect the cubes. The pipes guide the logical computation and the information flow between the code patches over spacetime.

__init__(name: str = '') None#

Methods

__init__([name])

add_edge(u, v[, kind])

Add an edge to the graph.

add_node(node[, check_conflict])

Add a node to the graph.

edges_at(position)

Get the edges incident to a position.

from_dae_file(filename[, graph_name])

Construct a block graph from a DAE file.

from_zx_graph(zx_graph[, name])

Construct the block graph from a ZX graph.

get_abstract_observables([correlation_surfaces])

Get all the abstract observables from the block 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.

shift_min_z_to_zero()

Shift the whole graph in the z direction to make the minimum z equal zero.

to_dae_file(file_path[, pipe_length, ...])

Write the block graph to a Collada DAE file.

to_zx_graph([name])

Convert the block graph to a ZX graph.

validate()

Check the validity of the block structures represented by the graph.

view_as_html([write_html_filepath, ...])

View COLLADA model in html with the help of three.js.

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.