ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Graph/Directed.pm
(Generate patch)

Comparing COMP/SCRAM/src/Graph/Directed.pm (file contents):
Revision 1.1 by sashby, Tue Jul 20 12:02:52 2004 UTC vs.
Revision 1.2 by sashby, Fri Dec 10 13:41:40 2004 UTC

# Line 0 | Line 1
1 + package Graph::Directed;
2 + use strict;
3 + local $^W = 1;
4 + use Graph::Base;
5 + use vars qw(@ISA);
6 + @ISA = qw(Graph::Base);
7 +
8 + sub new
9 +   {
10 +   my $class = shift;
11 +   my $G = Graph::Base->new(@_);
12 +  
13 +   bless $G, $class;
14 +   $G->directed(1);
15 +   return $G;
16 +   }
17 +
18 + sub _edges
19 +   {
20 +   my ($G, $u, $v) = @_;
21 +   my @e;
22 +  
23 +   if (defined $u and defined $v)
24 +      {
25 +      @e = ($u, $v)
26 +         if exists $G->{ Succ }->{ $u }->{ $v };
27 +      }
28 +   elsif (defined $u)
29 +      {
30 +      foreach $v ($G->successors($u))
31 +         {
32 +         push @e, $G->_edges($u, $v);
33 +         }
34 +      }
35 +   elsif (defined $v)
36 +      { # not defined $u and defined $v
37 +      foreach $u ($G->predecessors($v))
38 +         {
39 +         push @e, $G->_edges($u, $v);
40 +         }
41 +      }
42 +   else
43 +      {                         # not defined $u and not defined $v
44 +      foreach $u ($G->vertices)
45 +         {
46 +         push @e, $G->_edges($u);
47 +         }
48 +      }
49 +  
50 +   return @e;
51 +   }
52 +
53 + 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines