1Graph::Easy::Edge(3)  User Contributed Perl Documentation Graph::Easy::Edge(3)
2
3
4

NAME

6       Graph::Easy::Edge - An edge (a path connecting one ore more nodes)
7

SYNOPSIS

9               use Graph::Easy;
10
11               my $ssl = Graph::Easy::Edge->new(
12                       label => 'encrypted connection',
13                       style => 'solid',
14               );
15               $ssl->set_attribute('color', 'red');
16
17               my $src = Graph::Easy::Node->new('source');
18
19               my $dst = Graph::Easy::Node->new('destination');
20
21               $graph = Graph::Easy->new();
22
23               $graph->add_edge($src, $dst, $ssl);
24
25               print $graph->as_ascii();
26

DESCRIPTION

28       A "Graph::Easy::Edge" represents an edge between two (or more) nodes in
29       a simple graph.
30
31       Each edge has a direction (from source to destination, or back and
32       forth), plus a style (line width and style), colors etc. It can also
33       have a label, e.g. a text associated with it.
34
35       During the layout phase, each edge also contains a list of path-
36       elements (also called cells), which make up the path from source to
37       destination.
38

METHODS

40   error()
41               $last_error = $edge->error();
42
43               $cvt->error($error);                    # set new messages
44               $cvt->error('');                        # clear error
45
46       Returns the last error message, or '' for no error.
47
48   as_ascii()
49               my $ascii = $edge->as_ascii();
50
51       Returns the edge as a little ascii representation.
52
53   as_txt()
54               my $txt = $edge->as_txt();
55
56       Returns the edge as a little Graph::Easy textual representation.
57
58   label()
59               my $label = $edge->label();
60
61       Returns the label (also known as 'name') of the edge.
62
63   name()
64               my $label = $edge->name();
65
66       To make the interface more consistent, the "name()" method of an edge
67       can also be called, and it will returned either the edge label, or the
68       empty string if the edge doesn't have a label.
69
70   style()
71               my $style = $edge->style();
72
73       Returns the style of the edge, like 'solid', 'dotted', 'double', etc.
74
75   nodes()
76               my @nodes = $edge->nodes();
77
78       Returns the source and target node that this edges connects as objects.
79
80   bidirectional()
81               $edge->bidirectional(1);
82               if ($edge->bidirectional())
83                 {
84                 }
85
86       Returns true if the edge is bidirectional, aka has arrow heads on both
87       ends.  An optional parameter will set the bidirectional status of the
88       edge.
89
90   undirected()
91               $edge->undirected(1);
92               if ($edge->undirected())
93                 {
94                 }
95
96       Returns true if the edge is undirected, aka has now arrow at all.  An
97       optional parameter will set the undirected status of the edge.
98
99   has_ports()
100               if ($edge->has_ports())
101                 {
102                 ...
103                 }
104
105       Return true if the edge has restriction on the starting or ending port,
106       e.g. either the "start" or "end" attribute is set on this edge.
107
108   start_port()
109               my $port = $edge->start_port();
110
111       Return undef if the edge does not have a fixed start port, otherwise
112       returns the port as "side, number", for example "south, 0".
113
114   end_port()
115               my $port = $edge->end_port();
116
117       Return undef if the edge does not have a fixed end port, otherwise
118       returns the port as "side, number", for example "south, 0".
119
120   from()
121               my $from = $edge->from();
122
123       Returns the node that this edge starts at. See also "to()".
124
125   to()
126               my $to = $edge->to();
127
128       Returns the node that this edge leads to. See also "from()".
129
130   start_at()
131               $edge->start_at($other);
132               my $other = $edge->start_at('some node');
133
134       Set the edge's start point to the given node. If given a node name,
135       will add that node to the graph first.
136
137       Returns the new edge start point node.
138
139   end_at()
140               $edge->end_at($other);
141               my $other = $edge->end_at('some other node');
142
143       Set the edge's end point to the given node. If given a node name, will
144       add that node to the graph first.
145
146       Returns the new edge end point node.
147
148   flip()
149               $edge->flip();
150
151       Swaps the "start" and "end" nodes on this edge, e.g. reverses the
152       direction of the edge.
153
154   flow()
155               my $flow = $edge->flow();
156
157       Returns the flow for this edge, honoring inheritance. An edge without a
158       specific flow set will inherit the flow from the node it comes from.
159
160   edge_flow()
161               my $flow = $edge->edge_flow();
162
163       Returns the flow for this edge, or undef if it has none set on either
164       the object itself or its class.
165
166   port()
167               my ($side, $number) = $edge->port('start');
168               my ($side, $number) = $edge->port('end');
169
170       Return the side and port number where this edge starts or ends.
171
172       Returns undef for $side if the edge has no port restriction. The
173       returned side will be one absolute direction of "east", "west", "north"
174       or "south", depending on the port restriction and flow at that edge.
175
176   get_attributes()
177               my $att = $object->get_attributes();
178
179       Return all effective attributes on this object (graph/node/group/edge)
180       as an anonymous hash ref. This respects inheritance and default values.
181
182       See also raw_attributes().
183
184   raw_attributes()
185               my $att = $object->get_attributes();
186
187       Return all set attributes on this object (graph/node/group/edge) as an
188       anonymous hash ref. This respects inheritance, but does not include
189       default values for unset attributes.
190
191       See also get_attributes().
192
193   attribute related methods
194       You can call all the various attribute related methods like
195       "set_attribute()", "get_attribute()", etc. on an edge, too. For
196       example:
197
198               $edge->set_attribute('label', 'by train');
199               my $attr = $edge->get_attributes();
200               my $raw_attr = $edge->raw_attributes();
201
202       You can find more documentation in Graph::Easy.
203

EXPORT

205       None by default.
206

SEE ALSO

208       Graph::Easy.
209

AUTHOR

211       Copyright (C) 2004 - 2008 by Tels <http://bloodgate.com>.
212
213       See the LICENSE file for more details.
214
215
216
217perl v5.34.0                      2021-07-22              Graph::Easy::Edge(3)
Impressum