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,
Graph::Maker::HexGrid
Graph.pm
*---* / \ *---* *---* / \ / \ 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.
dims
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 graph_maker or Graph->new().
graph_maker
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.
undirected => 1
House of Graphs entries for graphs here include
Graph::Maker, Graph::Maker::Cycle, Graph::Maker::Grid
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/.
To install Graph::Maker::Other, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Graph::Maker::Other
CPAN shell
perl -MCPAN -e shell install Graph::Maker::Other
For more information on module installation, please visit the detailed CPAN module installation guide.