Maker/Barbell.pm

filter: Statementstmt 100% 39 / 39 Branchbran 91.6% 11 / 12 Conditioncond 40.0% 4 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 81.3% 61 / 75 CC 15 SCAR 24.6
CC
15
Cov
89%
init
16.0
__ANON__
1.1
BEGIN
1.0
CRAP 11.7
« Maker/BalancedTree.pm ↑ Summary Maker/Lollipop.pm »
1 package Graph::Maker::Barbell;
2
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use base qw/Graph::Maker/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Graph;
Subroutine BEGIN: called CC=1 SCAR=0.0
8
9 2 our $VERSION = '0.01';
10
11 sub init
12 2 ▶{
Subroutine init: called CC=15 SCAR=27.7
Pod undocumented
13 2 my ($self, %params) = @_;
14
15 2 ▶ my $n1 = delete($params{N1}) || 0;
Condition50%1/2
delete $params{'N1'} || 0
l!l
20
MC/DC0%0/1
delete $params{'N1'} || 0
delete $params{'N1'}
Truth table50%1/2
A
A= delete $params{'N1'}
Aresult
11
00
16 2 ▶ my $n2 = delete($params{N2}) || 0;
Condition50%1/2
delete $params{'N2'} || 0
l!l
20
MC/DC0%0/1
delete $params{'N2'} || 0
delete $params{'N2'}
Truth table50%1/2
A
A= delete $params{'N2'}
Aresult
11
00
17 2 my $gm = delete($params{graph_maker});
18 2 ▶ croak "graph_maker must be a reference to a function that creates a Graph.\n" if $gm && ref($gm) ne 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if $gm and ref $gm ne "CODE" 0 2 2
Condition33%1/3
$gm and ref $gm ne "CODE"
!ll&&!rl&&r
200
MC/DC0%0/2
$gm and ref $gm ne "CODE"
$gm ref $gm ne "CODE"
Truth table33%1/3
A and B
A= $gmB= ref $gm ne "CODE"
ABresult
0X0
100
111
19 2 ▶ $gm ||= sub { new Graph(@_); };
Subroutine __ANON__: called CC=1 SCAR=0.6
Condition33%1/3
$gm ||= sub { "Graph"->new(@_); }
l!l&&r!l&&!r
020
MC/DC0%0/2
$gm ||= sub { "Graph"->new(@_); }
$gm sub { "Graph"->new(@_); }
Truth table33%1/3
A ||= B
A= $gmB= sub { "Graph"->new(@_); }
ABresult
1X1
011
000
20
21 2 my $g = $gm->(%params);
22
23 # Left
24 2 for my $u(1..$n1)
25 {
26 8 ▶ my $min = $g->is_directed() ? 1 : $u+1;
Branch: 1 branch
BranchTrueFalseTotal
$g->is_directed ? : 4 4 8
27 8 for my $v($min..$n1)
28 {
29 22 ▶ next if $u == $v;
Branch: 1 branch
BranchTrueFalseTotal
if $u == $v 4 18 22
30 18 $g->add_edge($u, $v);
31 }
32 }
33 # Bar
34 2 $g->add_path($n1..$n1+$n2+1);
35 2 ▶ $g->add_path(reverse $n1..$n1+$n2+1) if $g->is_directed();
Branch: 1 branch
BranchTrueFalseTotal
if $g->is_directed 1 1 2
36 # Right
37 2 for my $u(1..$n1)
38 {
39 8 ▶ my $min = $g->is_directed() ? 1 : $u+1;
Branch: 1 branch
BranchTrueFalseTotal
$g->is_directed ? : 4 4 8
40 8 for my $v($min..$n1)
41 {
42 22 ▶ next if $u == $v;
Branch: 1 branch
BranchTrueFalseTotal
if $u == $v 4 18 22
43 18 $g->add_edge($n1+$n2+$u, $n1+$n2+$v);
44 }
45 }
46
47 2 return $g;
48 }
49
50 2 Graph::Maker->add_factory_type( 'barbell' => __PACKAGE__ );
51
52 2 1;
53
54 __DATA__
« Maker/BalancedTree.pm ↑ Summary Maker/Lollipop.pm »