ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Graph/Directed.pm
Revision: 1.3
Committed: Fri Jan 14 17:36:42 2011 UTC (14 years, 3 months ago) by muzaffar
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
State: FILE REMOVED
Log Message:
merged SCRAM_V2 branch in to head

File Contents

# Content
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;