++ed by:

1 non-PAUSE user.

and 1 contributors

# NAME

Graph::Maker::HexGrid - create hexagonal grid graphs

# SYNOPSIS

`````` use Graph::Maker::HexGrid;
\$graph = Graph::Maker->new ('hex_grid');``````

# DESCRIPTION

`Graph::Maker::HexGrid` creates a `Graph.pm` graph of hexagons arranged in a hexagonal shape,

``````                  *---*
/     \
*---*       *---*
/     \     /     \               dims => [4,3,2]
*---*       *---*       *---*
/     \     /     \     /     \
*       *---*       *---*       *---*
\     /     \     /     \     /     \
*---*       *---*       *---*       *
/     \     /     \     /     \     /
*       *---*       *---*       *---*
\     /     \     /     \     /     \
*---*       *---*       *---*       *
\     /     \     /     \     /
*---*       *---*       *---*
\     /     \     /
*---*       *---*
\     /
*---*``````

`dims` is the side lengths of the hexagonal shape. The example above is 4 hexagons along the bottom left side, then 3 for the bottom right, and 2 vertically. The opposite sides the same 4,3,2.

If a side is 1 then the result is a parallelogram of hexagons.

``````                  *---*
/     \
*---*       *---*
/     \     /     \              dims => [4,3,1]
*---*       *---*       *---*
/     \     /     \     /     \
*       *---*       *---*       *---*
\     /     \     /     \     /     \
*---*       *---*       *---*       *
\     /     \     /     \     /
*---*       *---*       *---*
\     /     \     /
*---*       *---*
\     /
*---*                 ``````

If two sides are 1 then the result is line of hexagons, like a ladder (Graph::Maker::Ladder) with every second rung.

``````      *---*
/     \                            dims => [3,1,1]
*       *---*
\     /     \
*---*       *---*
\     /     \
*---*       *
\     /
*---*     ``````

The order in which `dims` are given doesn't matter. Any cyclic rotation is just the graph rotated, and reversing is a mirror image, so any order is an isomorphic graph.

Vertex names are currently x,y coordinates used in the construction, but don't rely on that.

# FUNCTIONS

`\$graph = Graph::Maker->new('hex_grid', key => value, ...)`

The key/value parameters are

``````    dims        => arrayref of 3 integers
graph_maker => subr(key=>value) constructor, default Graph->new``````

Other parameters are passed to the constructor, either `graph_maker` or `Graph->new()`.

If the graph is directed (the default) then edges are added both ways between vertices (like Graph::Maker::Grid does). Option `undirected => 1` creates an undirected graph and for it there is a single edge between vertices.

# HOUSE OF GRAPHS

House of Graphs entries for graphs here include

1,1,1 https://hog.grinvin.org/ViewGraphInfo.action?id=670 6-cycle
2,2,2 https://hog.grinvin.org/ViewGraphInfo.action?id=28529
3,3,3 https://hog.grinvin.org/ViewGraphInfo.action?id=28500

# OEIS

Entries in Sloane's Online Encyclopedia of Integer Sequences related to this tree include

``    A143366    Wiener index of NxNxN``