NAME
Graph::Simple::Edge - An edge (a path from one node to another)
SYNOPSIS
use Graph::Simple;
my $ssl = Graph::Simple::Edge->new(
name => '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 name, e.g. a text associated with it.
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.
name()
my $name = $edge->name();
Returns the name (also known as 'label') of the edge.
style()
my $style = $edge->style();
Returns the style of the edge.
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( $x, $y, $type);
Add a new cell at position $x
and $y
with type $type
to the edge.
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 types for each cell, see cell_type() for a list of possible types.
cell_type()
$cell_type = $edge->cell_type( $x, $y );
Return the type of the cell located at $x, $y
. Returns undef if the cell does not belong to this edge.
Yo $edge->cell_type( $x, $y, $new_type );
The type is one of the following:
Type name Picture Description
EDGE_SHORT |-> start and end point at same cell
EDGE_START |-- starting-point
EDGE_END --> end-point
EDGE_HOR -- horizontal line
EDGE_VER | vertical line
EDGE_CROSS + crossing lines
EXPORT
None by default. Can export the following on request:
EDGE_SHORT
EDGE_START
EDGE_END
EDGE_HOR
EDGE_VER
EDGE_CROSS
EDGE_N_E
EDGE_N_W
EDGE_S_E
EDGE_S_W
EDGE_N_E_W
EDGE_S_E_W
EDGE_W_N_S
EDGE_E_N_S
TODO
Different ASCII styles:
,-----, +-----+
| Foo | --, vs. | Foo | --+
|_____| | +-----+ |
| |
SEE ALSO
AUTHOR
Copyright (C) 2004 - 2005 by Tels http://bloodgate.com
LICENSE
This library is free software; you can redistribute it and/or modify it under the terms of the GPL. See the LICENSE file for more details.