tqec.computation.base_graph.ComputationGraph#
- class ComputationGraph(name: str = '')[source]#
Base class for graph data structures representing a logical computation.
Methods
__init__
([name])add_node
(node[, check_conflict])Add a node to the graph.
edges_at
(position)Get the edges incident to a position.
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.
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.