Graph::Layouter - lay out graph onto an abstract plane
my $graph = new Graph; ... use Graph::Layouter; my $layouted = Graph::Layouter::layout($graph); use Graph::Layouter qw(layout); my $layouted = layout($graph); use Graph::Layouter; my $layouted = Graph::Layouter->layout($graph); ... $layouted->layout();
This module provides an abstract class for various algorithms of graph nodes positioning at a virtual surface. That is, if you have a graph stuffed into a Graph object, Graph::Layouter will take it and assign each node in the graph virtual coordinates in a plane.
Graph
Graph::Layouter
Graph::Layouter does not do anything besides assigning the coordinates --- you will need to have the nodes and edges laid out to some real plane on your own, or use a bundled Graph::Renderer modules family.
Graph::Renderer
This module contains only the abstract class, you will probably want to get an instance of some particular layouting algorithm instead; Graph::Layouter::Spring is bundled with this distribution. The general interface for all the subclasses is described below, but be sure consult also the particular class' documentation for remarks, special notes and specific extensions.
Graph::Layouter::Spring
This subroutine is the only entry point of this module, taking a given graph and laying it out appropriately. The subroutine can be called in several ways:
The subroutine can be called as a function (it is not automatically exported, but you can import it on your own if you really want; see the synopsis above). It takes one parameter, the Graph class (or any descendant) instance. It will set the layout back into the graph and return its parameter back for convenience.
TODO
The layouting function saves the layout data (coordinates of nodes) back to the Graph object, in a form of vertex attributes - layout_pos1 and layout_pos2 (pos1 is the x dimension, pos2 the y dimension; it is planned to make it possible to layout in three or unlimited number of dimensions space).
layout_pos1
layout_pos2
pos1
pos2
We also provide layout_min1, layout_max1 as well as layout_min2, layout_max2 global graph attributes, containing the extreme values in the respective dimensions. This is usually needed to properly map the virtual coordinates to some physical points.
layout_min1
layout_max1
layout_min2
layout_max2
If you intend to use Graph attributes in conjunction with the Graph::Layouter, you are advised not to infrige the layout_ namespace. If you are writing a Graph::Layouter subclass, you are advised to put your attributes to a layout__subclassname_ namespace.
layout_
layout__subclassname_
Graph, Graph::Renderer
The object-oriented interface is missing as well as some more universal layout calling interface (hash parameters).
Copyright 2004 by Petr Baudis <pasky@ucw.cz>.
This code is distributed under the same copyright terms as Perl itself.
Version 0.02
$Id: Layouter.pm,v 1.2 2004/04/06 15:24:14 pasky Exp $
To install Graph::Layouter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Graph::Layouter
CPAN shell
perl -MCPAN -e shell install Graph::Layouter
For more information on module installation, please visit the detailed CPAN module installation guide.