Revision: | 1.2 |
Committed: | Fri Dec 10 13:41:40 2004 UTC (20 years, 5 months ago) by sashby |
Content type: | text/plain |
Branch: | MAIN |
CVS Tags: | V1_1_7, V1_1_6, V1_1_5, V1_2_0-cand1, V1_1_4, V1_1_3, V1_1_2, V1_1_0_reltag8, V1_1_0_reltag7, V1_1_0_reltag6, V1_1_1, V1_1_0_reltag5, V1_1_0_reltag4, V1_1_0_reltag3, V1_1_0_reltag2, V1_1_0_reltag1, V1_1_0_reltag, V1_0_3-p4, V1_1_0_cand3, V1_1_0_cand2, V1_1_0_cand1, HEAD_SM_071214, forV1_1_0, v103_xml_071106, V1_0_3-p3, V1_0_3-p2, V1_1_0, v110p1, V110p6, V110p5, V110p4, V110p3, before110xmlBRmerge, V110p2, V110p1, V1_0_4p1, V1_0_3-p1, V1_0_3, V1_0_2, V1_0_2_p1, v102p1, V1_0_1, V1_0_0 |
Branch point for: | forBinLess_SCRAM, HEAD_BRANCH_SM_071214, v200branch, v103_with_xml, v103_branch |
Changes since 1.1: | +53 -0 lines |
Log Message: | Merged V1_0 branch to HEAD |
# | 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; |