rustworkx.generators.hexagonal_lattice_graph#
- hexagonal_lattice_graph(rows, cols, /, multigraph=True)#
Generate an undirected hexagonal lattice graph.
- Parameters:
rows (int) – The number of rows to generate the graph with.
cols (int) – The number of columns to generate the graph with.
multigraph (bool) – When set to
False
the outputPyGraph
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 hexagonal lattice graph.
- Return type:
- Raises:
TypeError – If either
rows
orcols
are not specified
import rustworkx.generators from rustworkx.visualization import mpl_draw graph = rustworkx.generators.hexagonal_lattice_graph(2, 2) mpl_draw(graph)