1 # -*-Perl-*- Test Harness script for Bioperl
9 test_begin(-tests => 28,
10 -requires_module => 'Graph');
12 use_ok('Bio::Ontology::SimpleGOEngine::GraphAdaptor');
15 my $g=Bio::Ontology::SimpleGOEngine::GraphAdaptor->new();
16 my $graph_version=( defined($Graph::VERSION) && $Graph::VERSION >= 0.5 ) ? 'new' : 'old';
17 my $adaptor_class=$graph_version eq 'new' ?
18 'Bio::Ontology::SimpleGOEngine::GraphAdaptor' : 'Bio::Ontology::SimpleGOEngine::GraphAdaptor02';
19 is (ref $g, $adaptor_class);
21 $g->add_vertex('vertex0');
22 ok($g->has_vertex('vertex0'));
23 ok(!$g->has_vertex('vertex1'));
28 $g->add_edge('vertex0','vertex1');
29 ok($g->has_edge('vertex0','vertex1'));
30 ok(!$g->has_edge('vertex0','vertex'));
33 is ($e[0]->[0],'vertex0');
34 is ($e[0]->[1],'vertex1');
36 @e=$g->edges_at('vertex0');
38 is ($e[0]->[0], 'vertex0');
39 is ($e[0]->[1], 'vertex1');
41 @v=$g->predecessors('vertex1');
45 @v=$g->successors('vertex0');
49 @v=$g->source_vertices;
57 $g->set_vertex_attribute('vertex0','ATTR0','vertex0_ATTR0');
58 $g->set_vertex_attribute('vertex0','ATTR1','vertex0_ATTR1');
59 $g->set_vertex_attribute('vertex1','ATTR0','vertex1_ATTR0');
60 $g->set_vertex_attribute('vertex1','ATTR1','vertex1_ATTR1');
61 is ($g->get_vertex_attribute('vertex0','ATTR0'),'vertex0_ATTR0');
62 is ($g->get_vertex_attribute('vertex0','ATTR1'),'vertex0_ATTR1');
63 is ($g->get_vertex_attribute('vertex1','ATTR0'),'vertex1_ATTR0');
64 is ($g->get_vertex_attribute('vertex1','ATTR1'),'vertex1_ATTR1');
66 $g->set_edge_attribute('vertex0','vertex1','ATTR0','vertex0_vertex1_ATTR0');
67 $g->set_edge_attribute('vertex0','vertex1','ATTR1','vertex0_vertex1_ATTR1');
68 is ($g->get_edge_attribute('vertex0','vertex1','ATTR0'),'vertex0_vertex1_ATTR0');
69 is ($g->get_edge_attribute('vertex0','vertex1','ATTR1'),'vertex0_vertex1_ATTR1');