1 # -*-Perl-*- Test Harness script for Bioperl
10 test_begin(-tests => 28,
11 -requires_module => 'Graph');
13 use_ok('Bio::Ontology::SimpleGOEngine::GraphAdaptor');
16 my $g=Bio::Ontology::SimpleGOEngine::GraphAdaptor->new();
17 my $graph_version=( defined($Graph::VERSION) && $Graph::VERSION >= 0.5 ) ? 'new' : 'old';
18 my $adaptor_class=$graph_version eq 'new' ?
19 'Bio::Ontology::SimpleGOEngine::GraphAdaptor' : 'Bio::Ontology::SimpleGOEngine::GraphAdaptor02';
20 is (ref $g, $adaptor_class);
22 $g->add_vertex('vertex0');
23 ok($g->has_vertex('vertex0'));
24 ok(!$g->has_vertex('vertex1'));
29 $g->add_edge('vertex0','vertex1');
30 ok($g->has_edge('vertex0','vertex1'));
31 ok(!$g->has_edge('vertex0','vertex'));
34 is ($e[0]->[0],'vertex0');
35 is ($e[0]->[1],'vertex1');
37 @e=$g->edges_at('vertex0');
39 is ($e[0]->[0], 'vertex0');
40 is ($e[0]->[1], 'vertex1');
42 @v=$g->predecessors('vertex1');
46 @v=$g->successors('vertex0');
50 @v=$g->source_vertices;
58 $g->set_vertex_attribute('vertex0','ATTR0','vertex0_ATTR0');
59 $g->set_vertex_attribute('vertex0','ATTR1','vertex0_ATTR1');
60 $g->set_vertex_attribute('vertex1','ATTR0','vertex1_ATTR0');
61 $g->set_vertex_attribute('vertex1','ATTR1','vertex1_ATTR1');
62 is ($g->get_vertex_attribute('vertex0','ATTR0'),'vertex0_ATTR0');
63 is ($g->get_vertex_attribute('vertex0','ATTR1'),'vertex0_ATTR1');
64 is ($g->get_vertex_attribute('vertex1','ATTR0'),'vertex1_ATTR0');
65 is ($g->get_vertex_attribute('vertex1','ATTR1'),'vertex1_ATTR1');
67 $g->set_edge_attribute('vertex0','vertex1','ATTR0','vertex0_vertex1_ATTR0');
68 $g->set_edge_attribute('vertex0','vertex1','ATTR1','vertex0_vertex1_ATTR1');
69 is ($g->get_edge_attribute('vertex0','vertex1','ATTR0'),'vertex0_vertex1_ATTR0');
70 is ($g->get_edge_attribute('vertex0','vertex1','ATTR1'),'vertex0_vertex1_ATTR1');