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::Layouter will take it and assign each node in the graph virtual coordinates in a plane.
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.
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.
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.
The layouting function saves the layout data (coordinates of nodes) back to the
Graph object, in a form of vertex attributes -
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).
We also provide
layout_max1 as well as
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.
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
The object-oriented interface is missing as well as some more universal layout calling interface (hash parameters).
Copyright 2004 by Petr Baudis <firstname.lastname@example.org>.
This code is distributed under the same copyright terms as Perl itself.
$Id: Layouter.pm,v 1.2 2004/04/06 15:24:14 pasky Exp $