use overload
'""' => \
&stringify
;
Graph::Directed - directed graphs
$g = new Graph::Directed;
See Graph::Base for the available methods.
Copyright 1999, O'Reilly & Associates.
This code is distributed under the same copyright terms as Perl itself.
# $D = Graph::Directed->new(@V)
# The Constructor. Returns a new directed graph $D, possibly
# populated with the optional initial vertices @V.
my $G = Graph
::Base
->new(@_);
# @e = $G->_edges($u, $v)
# Both vertices undefined:
# returns all the edges of the graph.
# returns all the edges between the vertices.
# Only 1st vertex defined:
# returns all the edges leading out of the vertex.
# Only 2nd vertex defined:
# returns all the edges leading into the vertex.
# Edges @e are returned as ($start_vertex, $end_vertex) pairs.
if (defined $u and defined $v) {
if exists $G->{ Succ
}->{ $u }->{ $v };
foreach $v ($G->successors($u)) {
push @e, $G->_edges($u, $v);
} elsif (defined $v) { # not defined $u and defined $v
foreach $u ($G->predecessors($v)) {
push @e, $G->_edges($u, $v);
} else { # not defined $u and not defined $v
foreach $u ($G->vertices) {
return $G->_stringify("-", ",");