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

NAME

Graph::Easy::Edge - An edge (a path from one node to another)

SYNOPSIS

        use Graph::Easy;

        my $ssl = Graph::Easy::Edge->new(
                label => 'encrypted connection',
                style => 'solid',
        );
        $ssl->set_attribute('color', 'red');

        my $src = Graph::Easy::Node->new('source');

        my $dst = Graph::Easy::Node->new('destination');

        $graph = Graph::Easy->new();

        $graph->add_edge($src, $dst, $ssl);

        print $graph->as_ascii();

DESCRIPTION

A Graph::Easy::Edge represents an edge between two (or more) nodes in a simple graph.

Each edge has a direction (from source to destination, or back and forth), plus a style (line width and style), colors etc. It can also have a label, e.g. a text associated with it.

Each edge also contains a list of path-elements (also called cells), which make up the path from source to destination.

METHODS

error()

        $last_error = $edge->error();

        $cvt->error($error);                    # set new messags
        $cvt->error('');                        # clear error

Returns the last error message, or '' for no error.

as_ascii()

        my $ascii = $edge->as_ascii();

Returns the edge as a little ascii representation.

as_txt()

        my $txt = $edge->as_txt();

Returns the edge as a little Graph::Easy textual representation.

label()

        my $label = $edge->label();

Returns the label (also known as 'name') of the edge.

style()

        my $style = $edge->style();

Returns the style of the edge, like 'solid', 'dotted', 'double', etc.

to_nodes()

        my @nodes = $edge->to_nodes();

Return the nodes this edge connects to, as objects.

from_nodes()

        my @nodes = $edge->from_nodes();

Return the nodes (that connections come from) as objects.

nodes()

        my @nodes = $edge->nodes();

Return all the nodes connected (in either direction) by this edge as objects.

add_cell()

        $edge->add_cell( $cell, $after );

Add a new cell to the edge. $cell must be an Graph::Easy::Edge::Cell object.

If the optional argument $after is a ref to a cell, then the new cell will be inserted right after this cell. If it is defined, but not a ref, the new cell will be inserted at the specified position.

clear_cells()

        $edge->clear_cells();

Removes all cells belonging to this edge.

cells()

        my $cells = $edge->cells();

Returns a hash containing all the cells this edge currently occupies. Keys on the hash are of the form of $x,$y e.g. 5,3 denoting cell at X = 5 and Y = 3. The values of the hash are the cell objects.

bidirectional()

        $edge->bidirectional(1);
        if ($edge->bidirectional())
          {
          }

Returns true if the edge is bidirectional, aka has arrow heads on both ends. An optional parameter will set the bidirectional status of the edge.

undirected()

        $edge->undirected(1);
        if ($edge->undirected())
          {
          }

Returns true if the edge is undirected, aka has now arrow at all. An optional parameter will set the undirected status of the edge.

has_ports()

        if ($edge->has_ports())
          {
          ...
          }

Return true if the edge has restriction on the starting or ending port, e.g. either the start or end attribute is set on this edge.

start_port()

        my $port = $edge->start_port();

Return undef if the edge does not have a fixed start port, otherwise returns the port as "side, number", for example "south, 0".

end_port()

        my $port = $edge->end_port();

Return undef if the edge does not have a fixed end port, otherwise returns the port as "side, number", for example "south, 0".

from()

        my $from = $edge->from();

Returns the node that this edge starts at. See also to().

to()

        my $to = $edge->to();

Returns the node that this edge leads to. See also from().

start_at()

        $edge->start_at($other);
        my $other = $edge->start_at('some node');

Set the edge's start point to the given node. If given a node name, will add that node to the graph first.

Returns the new edge start point node.

flow()

        my $flow = $edge->flow();
        my $flow = $edge->flow('start');
        my $flow = $edge->flow('end');

Returns the flow for this edge, or undef if it has none.

The optional parameter defines the attribute name to use as the base flow, and defaults to flow. When it is set to start, for example, the returned direction

port()

        my ($side, $number) = $edge->port('start');
        my ($side, $number) = $edge->port('end');

Return the side and port number where this edge starts or ends.

Returns undef for $side if the edge has no port restriction. The returned side will be one absolute direction of east, west, north or south, depending on the port restriction and flow at that edge.

EXPORT

None by default.

TODO

joints

Edges that join another edge.

SEE ALSO

Graph::Easy.

AUTHOR

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

See the LICENSE file for more details.