version increase for final release, improved warning
[bioperl-network.git] / t / Graph-MD5.t
blob8003d3c999f196507e7b768caa19851dc949b77f
1 # This is -*-Perl-*- code#
2 # Bioperl Test Harness Script for Modules#
3 # $Id: protgraph.t,v 1.1 2004/03/13 23:45:32 radams Exp
5 use vars qw($NUMTESTS $DEBUG $ERROR);
6 use strict;
7 $DEBUG = $ENV{'BIOPERLDEBUG'} || 0;
9 BEGIN {
10         # to handle systems with no installed Test module
11         # we include the t dir (where a copy of Test.pm is located)
12         # as a fallback
13         eval { require Test; };
14         $ERROR = 0;
15         if ( $@ ) {
16                 use lib 't';
17         }
18         use Test;
19         $NUMTESTS  = 19;
20         plan tests => $NUMTESTS;
21         eval { require Graph::Undirected; };
22         if ( $@ ) {
23                 warn("Graph required by the bioperl-network package, skipping tests");
24                 $ERROR = 1;
25         }
26         eval { require Digest::MD5; };
27         if ( $@ ) {
28                 warn("Digest::MD5 required for these tests, skipping tests");
29                 $ERROR = 1;
30         }
33 END {
34         foreach ( $Test::ntest..$NUMTESTS) {
35                 skip("Missing dependencies. Skipping tests",1);
36         }
38 exit 0 if $ERROR == 1;
41 # The purpose of these tests is to check to see if bugs have been 
42 # fixed in Perl's Graph, particularly refvertexed bugs
44 my $g = Graph::Undirected->new(refvertexed => 1);
46 ok 1;
48 my $seq1 = Digest::MD5->new;
49 my $seq2 = Digest::MD5->new;
50 my $seq3 = Digest::MD5->new;
51 my $seq4 = Digest::MD5->new;
53 my $str = "ljfgouyouiyougs";
55 $g->add_vertices($seq1,$seq2,$seq3,$seq4);
56 $g->add_edges([$seq1,$seq2],[$seq3,$seq4],[$seq3,$seq2]);
58 my @vs = $g->vertices; # OK
59 ok $vs[0]->add($str);
61 my $c = $g->complete; # OK
62 @vs = $c->vertices;
63 ok $vs[0]->add($str);
65 my $comp = $g->complement; # OK
66 @vs = $comp->vertices;
67 ok $vs[0]->add($str);
69 @vs = $g->interior_vertices; # OK
70 ok $vs[0]->add($str);
72 my $apsp = $g->APSP_Floyd_Warshall;
73 @vs = $apsp->path_vertices($seq1,$seq4); # OK
74 ok $vs[0]->add($str);
76 my $seq = $g->random_vertex; # OK
77 ok $seq->add($str);
79 my @rts = $g->articulation_points;
80 ok @rts;
82 my $t = Graph::Traversal::DFS->new($g);
83 $t->dfs;
84 @vs = $t->seen;
85 for my $seq (@vs) {
86         ok $seq->add($str); # NOT OK in version .73
89 @vs = $g->articulation_points; 
90 ok $vs[0]->add($str); # OK in version .70
91 ok scalar @vs, 2;
93 my @cc = $g->connected_components;
94 for my $ref (@cc) {
95         for my $seq (@$ref) {
96                 ok $seq->add($str); # OK in version .70
97         }
100 my @bs = $g->bridges;
101 ok $bs[0][0]->add($str); # NOT OK in version .73
103 my $cg = $g->connected_graph;
104 @vs = $cg->vertices;
105 # ok $vs[0]->add($str); # is my usage correct?
107 my @spd = $g->SP_Dijkstra($seq1,$seq4); # OK in version .70
109 my @spbf = $g->SP_Bellman_Ford($seq1,$seq4); # OK in version .70
111 __END__