File: 55_attributes.t

package info (click to toggle)
libgraph-perl 1%3A0.96-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,316 kB
  • ctags: 938
  • sloc: perl: 6,094; sh: 8; makefile: 2
file content (89 lines) | stat: -rw-r--r-- 2,061 bytes parent folder | download | duplicates (6)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use Test::More tests => 35;

use Graph;

{
    my $g = Graph->new;
    $g->add_weighted_vertex('a', 3);
    is($g, "a");
    is($g->get_vertex_weight('a'), 3);
}

{
    my $g = Graph->new;
    $g->add_vertex('x');
    $g->add_weighted_vertex('a', 3);
    is($g, "a,x");
    is($g->get_vertex_weight('a'), 3);
    is($g->get_vertex_weight('x'), undef);
    ok($g->has_vertex('a'));
    ok($g->has_vertex('x'));
}

{
    my $g = Graph->new;
    $g->add_edge('x', 'y');
    $g->add_weighted_edge('b', 'c', 4);
    is($g, "b-c,x-y");
    is($g->get_edge_weight('b', 'c'), 4);
    is($g->get_edge_weight('x', 'y'), undef);
    ok($g->has_vertex('b'));
    ok($g->has_vertex('c'));
    ok($g->has_edge('b', 'c'));
    ok($g->has_vertex('x'));
    ok($g->has_vertex('y'));
    ok($g->has_edge('x', 'y'));
}

{
    my $g = Graph->new;
    $g->add_weighted_edge('b', 'c', 4);
    is($g, "b-c");
    is($g->get_edge_weight('b', 'c'), 4);
    ok($g->has_vertex('b'));
    ok($g->has_vertex('c'));
    ok($g->has_edge('b', 'c'));
}

{
    my $g = Graph->new;
    $g->add_vertex('a');
    $g->add_vertex('b');
    $g->add_vertex('c');
    $g->add_weighted_vertex('x', 3);
    is($g, "a,b,c,x");
    is($g->get_vertex_weight('a'), undef);
    is($g->get_vertex_weight('b'), undef);
    is($g->get_vertex_weight('c'), undef);
    is($g->get_vertex_weight('x'), 3);
}

{
    my $g = Graph->new;
    $g->add_edge('a', 'b');
    $g->add_edge('b', 'c');
    $g->add_edge('c', 'a');
    $g->add_weighted_edge('c', 'b', 4);
    is($g, "a-b,b-c,c-a,c-b");
    ok($g->has_vertex('a'));
    ok($g->has_vertex('b'));
    ok($g->has_vertex('c'));
    ok($g->has_edge('a', 'b'));
    ok($g->has_edge('b', 'c'));
    ok($g->has_edge('c', 'a'));
    ok($g->has_edge('c', 'b'));
}

{
    my $g = Graph->new;
    $g->add_vertex('a');
    $g->add_vertex('b');
    $g->add_vertex('c');
    $g->add_edge('a', 'b');
    $g->add_edge('a', 'c');
    $g->add_edge('c', 'd');
    $g->delete_vertex('b');
    $g->add_edge('a', 'b');
    $g->add_weighted_vertex('e', 4);
    is($g, "a-b,a-c,c-d,e");
}