The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Graph::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.

METHODS

new()

        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($edge);
        $group->add_member($group);

Add the specified object to this group.

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.

Note that each object can only be a member of one group at a time.

add_edge()

        $group->add_edge($edge);

Add the specified edge to this group.

Note that each object can only be a member of one group at a time.

add_group()

        my $inner = $group->add_group('Group name');
        my $nested = $group->add_group($group);

Add a group as subgroup to this group.

del_member()

        $group->del_member($node);
        $group->del_member($edge);
        $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.

add_cell()

        $group->add_cell($cell);

Add a cell to the list of cells this group covers.

del_cell()

        $group->del_cell($cell);

Delete a cell from the list of cells this group covers.

cells()

        my @cells = $group->cells();

Returns a list of all cells that belong to this group.

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 belong to this group.

clear_cells()

        $group->clear_cells();

Clears the cells associated with this group.

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.

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();

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.

EXPORT

None by default.

SEE ALSO

Graph::Easy, Graph::Easy::Node, Graph::Easy::Manual.

AUTHOR

Copyright (C) 2004 - 2006 by Tels http://bloodgate.com

See the LICENSE file for more details.