rustworkx.generators.heavy_hex_graph#

heavy_hex_graph(d, multigraph=True)#

Generate an undirected heavy hex graph.

Fig. 2 of https://arxiv.org/abs/1907.09528 An ASCII diagram of the graph is given by:

... D-S-D   D ...
    |   |   |
...-F   F-S-F ...
    |   |   |
... D   D   D ...
    |   |   |
... F-S-F   F-...
    |   |   |
    .........
    |   |   |
... D   D   D ...
    |   |   |
...-F   F-S-F ...
    |   |   |
... D   D   D ...
    |   |   |
... F-S-F   F-...
    |   |   |
    .........
    |   |   |
... D   D   D ...
    |   |   |
...-F   F-S-F ...
    |   |   |
... D   D   D ...
    |   |   |
... F-S-F   F-...
    |   |   |
... D   D-S-D ...
Parameters:
  • d (int) – distance of the code. If d is set to 1 a PyGraph with a single node will be returned. d must be an odd number.

  • bidirectional – A parameter to indicate if edges should exist in both directions between nodes. Defaults to False.

  • multigraph (bool) – When set to False the output PyGraph object 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 hex graph

Return type:

PyGraph

Raises:

IndexError – If d is even.

import rustworkx.generators
from rustworkx.visualization import graphviz_draw

graph = rustworkx.generators.heavy_hex_graph(3)
graphviz_draw(graph, lambda node: dict(
        color='black', fillcolor='lightblue', style='filled'))
../_images/rustworkx.generators.heavy_hex_graph_0_0.png