1Graph::Easy::Group(3) User Contributed Perl DocumentationGraph::Easy::Group(3)
2
3
4

NAME

6       Graph::Easy::Group - A group of nodes (aka subgraph) in Graph::Easy
7

SYNOPSIS

9               use Graph::Easy;
10
11               my $bonn = Graph::Easy::Node->new('Bonn');
12
13               $bonn->set_attribute('border', 'solid 1px black');
14
15               my $berlin = Graph::Easy::Node->new( name => 'Berlin' );
16
17               my $cities = Graph::Easy::Group->new(
18                       name => 'Cities',
19               );
20               $cities->set_attribute('border', 'dashed 1px blue');
21
22               $cities->add_nodes ($bonn);
23               # $bonn will be ONCE in the group
24               $cities->add_nodes ($bonn, $berlin);
25

DESCRIPTION

27       A "Graph::Easy::Group" represents a group of nodes in an "Graph::Easy"
28       object. These nodes are grouped together on output.
29

METHODS

31   new()
32               my $group = Graph::Easy::Group->new( $options );
33
34       Create a new, empty group. $options are the possible options, see
35       Graph::Easy::Node for a list.
36
37   error()
38               $last_error = $group->error();
39
40               $group->error($error);                  # set new messages
41               $group->error('');                      # clear error
42
43       Returns the last error message, or '' for no error.
44
45   as_ascii()
46               my $ascii = $group->as_ascii();
47
48       Return the group as a little box drawn in ASCII art as a string.
49
50   name()
51               my $name = $group->name();
52
53       Return the name of the group.
54
55   id()
56               my $id = $group->id();
57
58       Returns the group's unique ID number.
59
60   set_attribute()
61               $group->set_attribute('border-style', 'none');
62
63       Sets the specified attribute of this (and only this!) group to the
64       specified value.
65
66   add_member()
67               $group->add_member($node);
68               $group->add_member($group);
69
70       Add the specified object to this group and returns this member. If the
71       passed argument is a scalar, will treat it as a node name.
72
73       Note that each object can only be a member of one group at a time.
74
75   add_node()
76               $group->add_node($node);
77
78       Add the specified node to this group and returns this node.
79
80       Note that each object can only be a member of one group at a time.
81
82   add_edge(), add_edge_once()
83               $group->add_edge($edge);                # Graph::Easy::Edge
84               $group->add_edge($from, $to);           # Graph::Easy::Node or
85                                                       # Graph::Easy::Group
86               $group->add_edge('From', 'To');         # Scalars
87
88       If passed an Graph::Easy::Edge object, moves the nodes involved in this
89       edge to the group.
90
91       if passed two nodes, adds these nodes to the graph (unless they already
92       exist) and adds an edge between these two nodes. See add_edge_once() to
93       avoid creating multiple edges.
94
95       This method works only on groups that are part of a graph.
96
97       Note that each object can only be a member of one group at a time, and
98       edges are automatically a member of a group if and only if both the
99       target and the destination node are a member of the same group.
100
101   add_group()
102               my $inner = $group->add_group('Group name');
103               my $nested = $group->add_group($group);
104
105       Add a group as subgroup to this group and returns this group.
106
107   del_member()
108               $group->del_member($node);
109               $group->del_member($group);
110
111       Delete the specified object from this group.
112
113   del_node()
114               $group->del_node($node);
115
116       Delete the specified node from this group.
117
118   del_edge()
119               $group->del_edge($edge);
120
121       Delete the specified edge from this group.
122
123   add_nodes()
124               $group->add_nodes($node, $node2, ... );
125
126       Add all the specified nodes to this group and returns them as a list.
127
128   nodes()
129               my @nodes = $group->nodes();
130
131       Returns a list of all node objects that belong to this group.
132
133   edges()
134               my @edges = $group->edges();
135
136       Returns a list of all edge objects that lead to or from this group.
137
138       Note: This does not return edges between nodes that are inside the
139       group, for this see edges_within().
140
141   edges_within()
142               my @edges_within = $group->edges_within();
143
144       Returns a list of all edge objects that are inside this group, in
145       arbitrary order. Edges are automatically considered inside a group if
146       their starting and ending node both are in the same group.
147
148       Note: This does not return edges between this group and other groups,
149       nor edges between this group and nodes outside this group, for this see
150       edges().
151
152   groups()
153               my @groups = $group->groups();
154
155       Returns the contained groups of this group as Graph::Easy::Group
156       objects, in arbitrary order.
157
158   groups_within()
159               # equivalent to $group->groups():
160               my @groups = $group->groups_within();           # all
161               my @toplevel_groups = $group->groups_within(0); # level 0 only
162
163       Return the groups that are inside this group, up to the specified
164       level, in arbitrary order.
165
166       The default level is -1, indicating no bounds and thus all contained
167       groups are returned.
168
169       A level of 0 means only the direct children, and hence only the
170       toplevel groups will be returned. A level 1 means the toplevel groups
171       and their toplevel children, and so on.
172
173   as_txt()
174               my $txt = $group->as_txt();
175
176       Returns the group as Graph::Easy textual description.
177
178   _find_label_cell()
179               $group->_find_label_cell();
180
181       Called by the layouter once for each group. Goes through all cells of
182       this group and finds one where to attach the label to. Internal usage
183       only.
184
185   get_attributes()
186               my $att = $object->get_attributes();
187
188       Return all effective attributes on this object (graph/node/group/edge)
189       as an anonymous hash ref. This respects inheritance and default values.
190
191       See also raw_attributes().
192
193   raw_attributes()
194               my $att = $object->get_attributes();
195
196       Return all set attributes on this object (graph/node/group/edge) as an
197       anonymous hash ref. This respects inheritance, but does not include
198       default values for unset attributes.
199
200       See also get_attributes().
201
202   attribute related methods
203       You can call all the various attribute related methods like
204       "set_attribute()", "get_attribute()", etc. on a group, too. For
205       example:
206
207               $group->set_attribute('label', 'by train');
208               my $attr = $group->get_attributes();
209
210       You can find more documentation in Graph::Easy.
211
212   layout()
213       This routine should not be called on groups, it only works on the graph
214       itself.
215
216   shape()
217               my $shape = $group->shape();
218
219       Returns the shape of the group as string.
220
221   has_as_successor()
222               if ($group->has_as_successor($other))
223                 {
224                 ...
225                 }
226
227       Returns true if $other (a node or group) is a successor of this group,
228       e.g.  if there is an edge leading from this group to $other.
229
230   has_as_predecessor()
231               if ($group->has_as_predecessor($other))
232                 {
233                 ...
234                 }
235
236       Returns true if the group has $other (a group or node) as predecessor,
237       that is if there is an edge leading from $other to this group.
238
239   root_node()
240               my $root = $group->root_node();
241
242       Return the root node as Graph::Easy::Node object, if it was set with
243       the 'root' attribute.
244

EXPORT

246       None by default.
247

SEE ALSO

249       Graph::Easy, Graph::Easy::Node, Graph::Easy::Manual.
250

AUTHOR

252       Copyright (C) 2004 - 2008 by Tels <http://bloodgate.com>
253
254       See the LICENSE file for more details.
255
256
257
258perl v5.28.0                      2016-06-06             Graph::Easy::Group(3)
Impressum