Note
This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.
rustworkx.generators.heavy_square_graph#
- heavy_square_graph(d, multigraph=True)#
Generate an undirected heavy square graph.
Fig. 6 of https://arxiv.org/abs/1907.09528. An ASCII diagram of the graph is given by:
... S ... \ / \ ... D D D ... | | | ... F-S-F-S-F-... | | | ... D D D ... | | | ... F-S-F-S-F-... | | | ......... | | | ... D D D ... \ / \ ... S ...
Note
This function generates the four-frequency variant of the heavy square code. This function implements Fig 10.b left of the paper. This function doesn’t support the variant Fig 10.b right.
Note that if
dis set to1, aPyGraphwith a single node will be returned.- Parameters:
d (int) – distance of the code. If
dis set to1, aPyGraphwith a single node will be returned.dmust be an odd number.multigraph (bool) – When set to
Falsethe outputPyGraphobject will not be not be a multigraph and won’t allow parallel edges to be added. Instead calls which would create a parallel edge will update the existing edge.
- Returns:
The generated heavy square graph
- Return type:
- Raises:
IndexError – If
dis even
import rustworkx.generators from rustworkx.visualization import graphviz_draw graph = rustworkx.generators.heavy_square_graph(3) graphviz_draw(graph, lambda node: dict( color='black', fillcolor='lightblue', style='filled'))