File: 38_vertices_at.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 (32 lines) | stat: -rw-r--r-- 740 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
use Test::More tests => 12;

use Graph;
my $g = Graph->new(hypervertexed => 1);

$g->add_edge("a", "b");
$g->add_edge("b", "a");
$g->add_edge("a", ["b", "c"]);
$g->add_edge(["a", "b"], "c");
$g->add_edge(["c", "d"], "e");
$g->add_edge("d" ,"e");
$g->add_edge(["a", "b", "c"], "d");

sub at {
    join(" ", sort map { ref $_ ? "[@$_]" : $_ } $g->vertices_at(@_));
}

is( at("a"), "[a b c] [a b] [a]");
is( at("b"), "[a b c] [a b] [b c] [b]");
is( at("c"), "[a b c] [b c] [c d] [c]");
is( at("d"), "[c d] [d]");
is( at("e"), "[e]");
is( at("x"), "");

is( at("a", "b"), "[a b c] [a b]");
is( at("b", "a"), "[a b c] [a b]");
is( at("a", "c"), "[a b c]");
is( at("a", "d"), "");

is( at("a", "b", "c"), "[a b c]");
is( at("a", "b", "d"), "");