flamingpy.codes.NxStabilizerGraph¶
- class flamingpy.codes.NxStabilizerGraph(ec=None, code=None)[source]¶
Bases:
flamingpy.codes.graphs.stabilizer_graph.StabilizerGraph
An implementation of StabilizerGraph backed by a NetworkX graph.
See StabilizerGraph for more details.
- graph¶
The actual graph backend.
- Type
networkx.Graph
Methods
add_edge
(node1, node2[, common_vertex])Insert a node into the graph and return the updated stabilizer graph.
add_high_bound_point
(point)Add a boundary point with an edge to the 'high' point to the graph.
add_high_bound_points
(points)Add many boundary points with edges to the 'high' point to the graph.
add_low_bound_point
(point)Add a boundary point with an edge to the 'low' point to the graph.
add_low_bound_points
(points)Add many boundary points with edges to the 'low' point to the graph.
add_node
(node)Insert a node into the stabilizer graph.
add_stabilizer
(stabilizer)Add a stabilizer node to the stabilizer graph.
add_stabilizers
(stabilizers)Add many stabilizer nodes to the stabilizer graph.
assign_weights
(code)Assign the weights to the graph based on the weight of the common vertex of each stabilizer pair of the code.
Return an iterable for all boundary points of the graph.
Add an edge between each pair of nodes sharing a common vertex.
draw
(**kwargs)Draw the stabilizer graph with matplotlib.
edge_data
(node1, node2)Return a view of the edge data as a dict.
edges
()Return an iterable of node pairs corresponding to the edges of the graph.
Check if the graph has any boundary points.
neighbors
(node)Return the neighbours of node.
nodes
()Return an iterable of all nodes in the graph.
Return an iterable of all stabilizer nodes with an odd parity.
out_edges
(node)Return the edges incident to node.
Returns an iterable of all edges excluding the ones connected to the 'low' or 'high' points.
Return an iterable of all nodes excluding the 'low' and 'high' points.
Compute the shortest path from the 'high' node to every other node in the graph.
Compute the shortest path from the 'low' node to every other node in the graph.
shortest_paths_without_high_low
(source)Compute the shortest path from source to every other node in the graph, except the 'high' and 'low' connector.
to_nx
()Convert the same graph into a NxStabilizerGraph.
- add_edge(node1, node2, common_vertex=None)[source]¶
Insert a node into the graph and return the updated stabilizer graph.
This should not distinguish between stabilizer and boundary points.
- Parameters
node1 (Stabilizer or Tuple[Int, Int, Int]) – The first node of the edge.
node2 (Stabilizer or Tuple[Int, Int, Int]) – The second node of the edge.
common_vertex (optional) – The vertex shared by the two nodes in the corresponding code.
- Returns
The updated stabilizer graph.
- add_high_bound_point(point)¶
Add a boundary point with an edge to the ‘high’ point to the graph.
- Parameters
point (Tuple[int, int, int]) – The boundary point to add.
- Returns
The updated stabilizer graph.
- add_high_bound_points(points)¶
Add many boundary points with edges to the ‘high’ point to the graph.
- Parameters
points (iterable of Tuple[int, int, int]) – The boundary points to add.
- Returns
The updated stabilizer graph.
- add_low_bound_point(point)¶
Add a boundary point with an edge to the ‘low’ point to the graph.
- Parameters
point (Tuple[int, int, int]) – The boundary point to add.
- Returns
The updated stabilizer graph.
- add_low_bound_points(points)¶
Add many boundary points with edges to the ‘low’ point to the graph.
- Parameters
points (iterable of Tuple[int, int, int]) – The boundary points to add.
- Returns
The updated stabilizer graph.
- add_node(node)[source]¶
Insert a node into the stabilizer graph.
This should not distinguish between stabilizer and boundary points.
- Returns
The updated stabilizer graph.
- add_stabilizer(stabilizer)¶
Add a stabilizer node to the stabilizer graph.
- Parameters
stabilizer (Stabilizer) – The stabilizer to add.
- Returns
The updated stabilizer graph.
- add_stabilizers(stabilizers)¶
Add many stabilizer nodes to the stabilizer graph.
- Parameters
stabilizers (iterable of Stabilizer) – The stabilizers to add.
- Returns
The updated stabilizer graph.
- assign_weights(code)¶
Assign the weights to the graph based on the weight of the common vertex of each stabilizer pair of the code.
- bound_points()¶
Return an iterable for all boundary points of the graph.
- connect_nodes()¶
Add an edge between each pair of nodes sharing a common vertex.
- Returns
The updated stabilizer graph.
- draw(**kwargs)¶
Draw the stabilizer graph with matplotlib.
See flamingpy.utils.viz.draw_dec_graph for more details.
- edge_data(node1, node2)[source]¶
Return a view of the edge data as a dict.
- Parameters
node1 (Stabilizer or Tuple[Int, Int, Int]) – The first node of the edge.
node2 (Stabilizer or Tuple[Int, Int, Int]) – The second node of the edge.
- Raises
KeyError if there is no edge between the given nodes. –
- has_bound_points()¶
Check if the graph has any boundary points.
- odd_parity_stabilizers()¶
Return an iterable of all stabilizer nodes with an odd parity.
- real_edges()¶
Returns an iterable of all edges excluding the ones connected to the ‘low’ or ‘high’ points.
- real_nodes()¶
Return an iterable of all nodes excluding the ‘low’ and ‘high’ points.
- shortest_paths_from_high()[source]¶
Compute the shortest path from the ‘high’ node to every other node in the graph.
This assumes that the edge weights are asssigned.
- Returns
- The first dictionary maps a target node to the weight
of the corresponding path. The second one maps a target node to the list of nodes along the corresponding path.
- Return type
(dict, dict)
- shortest_paths_from_low()[source]¶
Compute the shortest path from the ‘low’ node to every other node in the graph.
This assumes that the edge weights are asssigned.
- Returns
- The first dictionary maps a target node to the weight
of the corresponding path. The second one maps a target node to the list of nodes along the corresponding path.
- Return type
(dict, dict)
- shortest_paths_without_high_low(source)[source]¶
Compute the shortest path from source to every other node in the graph, except the ‘high’ and ‘low’ connector.
This assumes that the edge weights are asssigned.
Note: a path can’t use the ‘high’ and ‘low’ node.
- Parameters
source – The source node for each path.
- Returns
- The first dictionary maps a target node to the weight
of the corresponding path. The second one maps a target node to the list of nodes along the corresponding path.
- Return type
(dict, dict)
- to_nx()¶
Convert the same graph into a NxStabilizerGraph.
This involves converting the graph representation to a networkx graph representation.