Graph::Easy::Group(3) User Contributed Perl DocumentationGraph::Easy::Group(3)NAMEGraph::Easy::Group - A group of nodes (aka subgraph) in Graph::Easy
SYNOPSIS
use Graph::Easy;
my $bonn = Graph::Easy::Node->new('Bonn');
$bonn->set_attribute('border', 'solid 1px black');
my $berlin = Graph::Easy::Node->new( name => 'Berlin' );
my $cities = Graph::Easy::Group->new(
name => 'Cities',
);
$cities->set_attribute('border', 'dashed 1px blue');
$cities->add_nodes ($bonn);
# $bonn will be ONCE in the group
$cities->add_nodes ($bonn, $berlin);
DESCRIPTION
A "Graph::Easy::Group" represents a group of nodes in an "Graph::Easy"
object. These nodes are grouped together on output.
METHODSnew()
my $group = Graph::Easy::Group->new( $options );
Create a new, empty group. $options are the possible options, see
Graph::Easy::Node for a list.
error()
$last_error = $group->error();
$group->error($error); # set new messags
$group->error(''); # clear error
Returns the last error message, or '' for no error.
as_ascii()
my $ascii = $group->as_ascii();
Return the group as a little box drawn in ASCII art as a string.
name()
my $name = $group->name();
Return the name of the group.
id()
my $id = $group->id();
Returns the group's unique ID number.
set_attribute()
$group->set_attribute('border-style', 'none');
Sets the specified attribute of this (and only this!) group to the
specified value.
add_member()
$group->add_member($node);
$group->add_member($group);
Add the specified object to this group and returns this member. If the
passed argument is a scalar, will treat it as a node name.
Note that each object can only be a member of one group at a time.
add_node()
$group->add_node($node);
Add the specified node to this group and returns this node.
Note that each object can only be a member of one group at a time.
add_edge(), add_edge_once()
$group->add_edge($edge); # Graph::Easy::Edge
$group->add_edge($from, $to); # Graph::Easy::Node or
# Graph::Easy::Group
$group->add_edge('From', 'To'); # Scalars
If passed an Graph::Easy::Edge object, moves the nodes involved in this
edge to the group.
if passed two nodes, adds these nodes to the graph (unless they already
exist) and adds an edge between these two nodes. See add_edge_once() to
avoid creating multiple edges.
This method works only on groups that are part of a graph.
Note that each object can only be a member of one group at a time, and
edges are automatically a member of a group if and only if both the
target and the destination node are a member of the same group.
add_group()
my $inner = $group->add_group('Group name');
my $nested = $group->add_group($group);
Add a group as subgroup to this group and returns this group.
del_member()
$group->del_member($node);
$group->del_member($group);
Delete the specified object from this group.
del_node()
$group->del_node($node);
Delete the specified node from this group.
del_edge()
$group->del_edge($edge);
Delete the specified edge from this group.
add_nodes()
$group->add_nodes($node, $node2, ... );
Add all the specified nodes to this group and returns them as a list.
nodes()
my @nodes = $group->nodes();
Returns a list of all node objects that belong to this group.
edges()
my @edges = $group->edges();
Returns a list of all edge objects that lead to or from this group.
Note: This does not return edges between nodes that are inside the
group, for this see edges_within().
edges_within()
my @edges_within = $group->edges_within();
Returns a list of all edge objects that are inside this group, in
arbitrary order. Edges are automatically considered inside a group if
their starting and ending node both are in the same group.
Note: This does not return edges between this group and other groups,
nor edges between this group and nodes outside this group, for this see
edges().
groups()
my @groups = $group->groups();
Returns the contained groups of this group as Graph::Easy::Group
objects, in arbitrary order.
groups_within()
# equivalent to $group->groups():
my @groups = $group->groups_within(); # all
my @toplevel_groups = $group->groups_within(0); # level 0 only
Return the groups that are inside this group, up to the specified
level, in arbitrary order.
The default level is -1, indicating no bounds and thus all contained
groups are returned.
A level of 0 means only the direct children, and hence only the
toplevel groups will be returned. A level 1 means the toplevel groups
and their toplevel children, and so on.
as_txt()
my $txt = $group->as_txt();
Returns the group as Graph::Easy textual description.
_find_label_cell()
$group->_find_label_cell();
Called by the layouter once for each group. Goes through all cells of
this group and finds one where to attach the label to. Internal usage
only.
get_attributes()
my $att = $object->get_attributes();
Return all effective attributes on this object (graph/node/group/edge)
as an anonymous hash ref. This respects inheritance and default values.
See also raw_attributes().
raw_attributes()
my $att = $object->get_attributes();
Return all set attributes on this object (graph/node/group/edge) as an
anonymous hash ref. This respects inheritance, but does not include
default values for unset attributes.
See also get_attributes().
attribute related methods
You can call all the various attribute related methods like
"set_attribute()", "get_attribute()", etc. on a group, too. For
example:
$group->set_attribute('label', 'by train');
my $attr = $group->get_attributes();
You can find more documentation in Graph::Easy.
layout()
This routine should not be called on groups, it only works on the graph
itself.
shape()
my $shape = $group->shape();
Returns the shape of the group as string.
has_as_successor()
if ($group->has_as_successor($other))
{
...
}
Returns true if $other (a node or group) is a successor of this group,
e.g. if there is an edge leading from this group to $other.
has_as_predecessor()
if ($group->has_as_predecessor($other))
{
...
}
Returns true if the group has $other (a group or node) as predecessor,
that is if there is an edge leading from $other to this group.
root_node()
my $root = $group->root_node();
Return the root node as Graph::Easy::Node object, if it was set with
the 'root' attribute.
EXPORT
None by default.
SEE ALSO
Graph::Easy, Graph::Easy::Node, Graph::Easy::Manual.
AUTHOR
Copyright (C) 2004 - 2008 by Tels <http://bloodgate.com>
See the LICENSE file for more details.
perl v5.14.1 2010-11-05 Graph::Easy::Group(3)