NAME
Graph::Geometric - create and work with geometric graphs
SYNOPSIS
use Graph::Geometric;
# Generate a truncated regular icosahedron
my $g = icosahedron->truncated;
# Count the faces
print scalar $g->faces;
DESCRIPTION
Graph::Geometric
is an extension of Graph
to support working with geometric (topologic) graphs. In addition to vertices and edges, Graph::Geometric
has a concept of faces to ease handling of geometric graphs. Graph::Geometric
does not provide coordinates for vertices as it is supposed to be used for topology analysis of geometric shapes.
As of now, Graph::Geometric
does not allow for arbitrary graph construction. Geometric graphs have to be built from simple polyhedra (constructors listed below) or derived from them by using modifiers such as stellation or truncation. Removal of vertices and faces is also supported.
ON THE STABILITY OF API
As Graph::Geometric
is in its early stages of development, not much of API stability can be promised. In particular, method names are likely to be changed for the sake of homogeneity. Names of generated vertices and order of faces returned by faces()
as well are likely to change. Some syntax sugar may also appear.
CONSTRUCTORS
antiprism( $N )
Given N, creates an N-gonal antiprism. If N is not given, returns a code reference to itself.
bipyramid( $N )
Given N, creates an N-gonal bipyramid. If N is not given, returns a code reference to itself.
cucurbituril( $N )
Given N, creates a geometric graph representing chemical structure of cucurbit[N]uril. Cucurbiturils do not exacly fit the definition of polyhedra, but have nevertheless interesting structures. If N is not given, returns a cucurbit[5]uril, the smallest naturally occurring cucurbituril.
cupola( $N )
Given N, creates an N-gonal cupola. If N is not given, returns a code reference to itself.
dodecahedron()
Creates a regular dodecahedron.
icosahedron()
Creates a regular icosahedron.
icosidodecahedron()
Creates an icosidodecahedron.
octahedron()
Creates a regular octahedron.
orthobicupola( $N )
Given N, creates an N-gonal orthobicupola. If N is not given, returns a code reference to itself. Implementation detail: orthobicupola is constructed by creating a prism, carving its side edges in half, joining the midpoints and removing every second edge on top and bottom faces.
prism( $N )
Given N, creates an N-gonal prism. If N is not given, returns a code reference to itself.
pyramid( $N )
Given N, creates an N-gonal pyramid. If N is not given, returns a code reference to itself.
rhombic_dodecahedron()
Creates a rhombic dodecahedron.
rotunda( $N )
Given N, creates an N-gonal rotunda. If N is not given, returns a code reference to itself.
tetrahedron()
Creates a regular tetrahedron.
trapezohedron( $N )
Creates an N-gonal trapezohedron. If N is not given, returns a code reference to itself.
ACCESSORS
faces( @vertices )
Returns an array of arrays listing vertices in each of polyhedron's faces. Vertex lists are returned sorted, they do not maintain the order of vertices in faces. Experimental: given a list of vertices, select only faces containing all of them.
GRAPH METHODS
deep_copy()
Creates a deep copy of a Graph::Geometric object.
delete_edge( $u, $v )
Deletes an edge by merging its vertices. Given edge is assumed to exist, a check will be implemented later. Modifies and returns the original object.
delete_face( $face )
Deletes a given face from polyhedra. A face is defined by an unordered list of vertices. Given face is assumed to exist, a check will be implemented later. Modifies and returns the original object.
delete_vertex( $v )
Handles vertex deletion by merging neighbouring faces. Modifies and returns the original object.
GEOMETRIC METHODS
carve_face( $u, $v )
Given a graph and a pair of vertices lying on the same face, add a new edge splitting the face in two. Subroutine dies if there is no face containing both vertices.
rectify()
Given a polyhedron, performs its rectification. Modifies and returns the original object.
stellate()
Given a polyhedron and a list of faces, performs stellation of specified faces. If no faces are given, all faces are stellated. Modifies and returns the original object.
truncate()
Given a polyhedron and a list of vertices, performs truncation of specified vertices. If no vertices are given, all vertices are stellated. Modifies and returns the original object.
dual()
Given a polyhedron, returns its dual as a new object. The original object is not modified.
OPERATORS
The following class methods take a single Graph::Geometric object, copy it, perform a certain operation and return the results. They allow for such syntactically sweet calls like:
my $cuboctahedron1 = rectified tetragonal prism;
my $cuboctahedron2 = rectified octahedron;
my $truncated_icosahedron = truncated icosahedron;
rectified()
Copies the given polyhedron, rectifies it and returns the rectified polyhedron.
stellated()
Copies the given polyhedron, stellates all its faces and returns the stellated polyhedron.
truncated()
Copies the given polyhedron, truncates all its vertices and returns the truncated polyhedron.
AUTHORS
Andrius Merkys, <merkys@cpan.org>