# flamingpy.codes.RxStabilizerGraph¶

class flamingpy.codes.RxStabilizerGraph(ec=None, code=None)[source]

An implementation of StabilizerGraph backed by a retworkx graph.

See StabilizerGraph for more details.

graph

The actual graph backend. This graph stores integer indices to represent nodes.

Type

retworkx.PyGraph

node_to_index

The map from nodes to the corresponding indices in the graph backend.

Type

dict

index_to_node

The map from indices in the graph backend to the corresponding nodes.

Type

dict

 add_edge(node1, node2[, common_vertex]) Insert a node into the graph and return the updated stabilizer graph. 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 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. 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. 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. Compute the shortest path from source to every other node in the graph, except the 'high' and 'low' connector. Convert the same graph into a NxStabilizerGraph.

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 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 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 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 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.

Insert a node into the stabilizer graph.

This should not distinguish between stabilizer and boundary points.

Returns

The updated stabilizer graph.

Add a stabilizer node to the stabilizer graph.

Parameters

stabilizer (Stabilizer) – The stabilizer to add.

Returns

The updated stabilizer graph.

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.

edges()[source]

Return an iterable of node pairs corresponding to the edges of the graph.

has_bound_points()

Check if the graph has any boundary points.

neighbors(node)[source]

Return the neighbours of node.

nodes()[source]

Return an iterable of all nodes in the graph.

odd_parity_stabilizers()

Return an iterable of all stabilizer nodes with an odd parity.

out_edges(node)[source]

Return the edges incident to node.

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.

Home

Background

Using FlamingPy

Development

Getting Help

Python API