Graph::Simple::Edge - An edge


NAME

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


SYNOPSIS

        use Graph::Simple;
        my $ssl = Graph::Simple::Edge->new(
                label => 'encrypted connection',
                style => '-->',
                color => 'red',
        );
        my $src = Graph::Simple::Node->new(
                name => 'source',
        );
        my $dst = Graph::Simple::Node->new(
                name => 'destination',
        );
        $graph = Graph::Simple->new();
        $graph->add_edge($src, $dst, $ssl);
        print $graph->as_ascii();


DESCRIPTION

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

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 '--', '==', '..', '- '.

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

Add a new cell to the edge. $cell should be an Graph::Simple::Path object.

clear_cells()

        $edge->clear_cells();

Removes all belonging cells.

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.


EXPORT

None by default.


TODO

joints

Edges that join another edge.


SEE ALSO

the Graph::Simple manpage.


AUTHOR

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

See the LICENSE file for more details.