File: 07complete.t

package info (click to toggle)
libgraph-perl 0.20102-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 184 kB
  • ctags: 132
  • sloc: perl: 1,455; makefile: 38
file content (41 lines) | stat: -rw-r--r-- 837 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use Graph;

use strict;
local $^W = 1;

print "1..8\n";

my $g = Graph->new;

$g->add_edge('a', 'b');
$g->add_edge('b', 'c');

my $h = $g->complete;

print "not " unless $h->edges == $h->vertices * ($h->vertices - 1);
print "ok 1\n";

print "not " unless join(" ", $h->vertices) eq "a b c";
print "ok 2\n";

print "not " unless $h->vertices == $g->vertices;
print "ok 3\n";

print "not " unless join(" ", $h->edges) eq "a b a c b a b c c a c b";
print "ok 4\n";

$g->delete_vertex('c');

print "not " unless join(" ", $h->vertices) eq "a b c";
print "ok 5\n";

print "not " unless join(" ", $h->edges) eq "a b a c b a b c c a c b";
print "ok 6\n";

$g->delete_edge('a', 'b');

print "not " unless join(" ", $h->vertices) eq "a b c";
print "ok 7\n";

print "not " unless join(" ", $h->edges) eq "a b a c b a b c c a c b";
print "ok 8\n";