File: 06_directed.t

package info (click to toggle)
libgraph-moreutils-perl 0.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 152 kB
  • sloc: perl: 385; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 572 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
#!/usr/bin/perl

use strict;
use warnings;
use Graph::Directed;
use Graph::MoreUtils qw( line );
use List::Util qw( all );
use Test::More tests => 7;

my( $g, $l );

$g = Graph::Directed->new;
$g->add_edge( 0, 0 );
$g->add_edge( 0, 1 );
$g->add_edge( 1, 0 );
$g->add_edge( 1, 1 );

is $g->edges, 4;

$l = line( $g );

is $l->vertices, 4;
is $l->edges, 8;

ok all { $l->in_degree( $_ ) == 2 && $l->out_degree( $_ ) == 2 } $l->vertices;

$l = line( $l );

is $l->vertices, 8;
is $l->edges, 16;

ok all { $l->in_degree( $_ ) == 2 && $l->out_degree( $_ ) == 2 } $l->vertices;