Graph::Maker::HexGrid - create hexagonal grid graphs
use Graph::Maker::HexGrid; $graph = Graph::Maker->new ('hex_grid');
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 other sides likewise 4,3,2.
If a side is 1 then the result is a parallelogram of hexagons.
*---* / \ *---* *---* / \ / \ dims => [3,2,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.
$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
If the graph is directed (the default) then edges are added both ways between vertices (like Graph::Maker::Grid does). Option
undirected => 1creates an undirected graph and for it there is a single edge between vertices.
House of Graphs entries for graphs here include
- 1,1,1 https://hog.grinvin.org/ViewGraphInfo.action?id=670 6-cycle
- 3,3,3 https://hog.grinvin.org/ViewGraphInfo.action?id=28500
Copyright 2017 Kevin Ryde
This file is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with This file. If not, see http://www.gnu.org/licenses/.