NAME

Graph::Element - a base class for all things graph

SYNOPSIS

Not to be used directly.

DESCRIPTION

This class is a base class for all the graph elements: vertices, edges, and the graphs themselves.

Though largely this class is for internal use only and will bite viciously if approached by strangers it does provide some public methods.

METHODS

$name = $element->name;

Get the current name of the element. Vertices always have names (they are defined by their names), edges and graphs not necessarily.

$element->name($new_name);

Set the name of the element.

VIRTUAL METHODS

This class also implements a "virtual method" for all the graph elements: if an unknown method is invoked on an element, it is assumed to be an attribute get/set method from then onwards. For example:

$graph->yabadabadoo('fred');
$flintstone = $graph->yabadabadoo;

$flintstone will be now 'fred'. This feature is both very comfortable and very uncomfortable: no need to separately define methods -- and a pain in nether parts if you are prone to typos.

ATTRIBUTE METHODS

If you want to play safe with the attributes (as opposed to the virtual attribute methods), you must use explicit language:

$attribute_value = $element->attribute($attribute_name);

Get the attribute of the element.

$element->attribute($attribute_name, $attribute_value);

Set the attribute of the element.

$element->delete_attribute($attribute_name);

Delete the attribute of the element. You can also

$element->attribute($attribute_name, undef)

but that doesn't really get rid of the attribute, the has_attribute method will still find the attribute, but after delete_attribute even that will fail.

Tests whether the element has the attribute, regardless of the value of the attribute.

SEE ALSO

Graph, Graph::Directed, Graph::Undirected.

VERSION

See Graph.

AUTHOR

Jarkko Hietaniemi, <jhi@iki.fi>

COPYRIGHT

Copyright 1998, O'Reilly & Associates.

This code is distributed under the same copyright terms as perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 207:

=pod directives shouldn't be over one line long! Ignoring all 2 lines of content