BiStar.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 6 / 6 Conditioncond 88.8% 8 / 9 MC/DCmcdc 80.0% 4 / 5 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 95.3% 61 / 64 CC 10 SCAR 17.3
CC
10
Cov
98%
init
9.0
_make_graph
2.0
BEGIN
1.0
CRAP 5.6
« TwindragonAreaTree.pm ↑ Summary Catalans.pm »
1 # Copyright 2017, 2018, 2019, 2020, 2021 Kevin Ryde
2 #
3 # This file is part of Graph-Maker-Other.
4 #
5 # This file is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the Free
7 # Software Foundation; either version 3, or (at your option) any later
8 # version.
9 #
10 # This file is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with Graph-Maker-Other. See the file COPYING. If not, see
17 # <http://www.gnu.org/licenses/>.
18  
19  
20 package Graph::Maker::BiStar;
21 1 ▶use 5.004;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Graph::Maker;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 1 ▶use vars '$VERSION','@ISA';
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 $VERSION = 19;
27 1 @ISA = ('Graph::Maker');
28  
29  
30 176 ▶sub _default_graph_maker {
Subroutine _default_graph_maker: called CC=1 SCAR=0.0
31 176 require Graph;
32 176 return Graph->new(@_);
33 }
34 176 ▶sub _make_graph {
Subroutine _make_graph: called CC=2 SCAR=7.1
35 176 my ($params) = @_;
36 176 ▶ my $graph_maker = delete($params->{'graph_maker'}) || \&_default_graph_maker;
Condition50%1/2
delete $params->{'graph_maker'} || \&Graph::Maker::BiStar::_default_graph_maker
l!l
0176
MC/DC0%0/1
delete $params->{'graph_maker'} || \&Graph::Maker::BiStar::_default_graph_maker
delete $params->{'graph_maker'}
Truth table50%1/2
A
A= delete $params->{'graph_maker'}
Aresult
11
00
37 176 return $graph_maker->(%$params);
38 }
39  
40 176 ▶sub init {
Subroutine init: called CC=9 SCAR=22.0
Pod undocumented
41 176 my ($self, %params) = @_;
42 176 ▶ my $N = delete($params{'N'}) || 0;
Condition100%2/2
delete $params{'N'} || 0
l!l
13640
MC/DC100%1/1
delete $params{'N'} || 0
delete $params{'N'}
Truth table100%2/2
A
A= delete $params{'N'}
Aresult
11
00
43 176 ▶ my $M = delete($params{'M'}) || 0;
Condition100%2/2
delete $params{'M'} || 0
l!l
13640
MC/DC100%1/1
delete $params{'M'} || 0
delete $params{'M'}
Truth table100%2/2
A
A= delete $params{'M'}
Aresult
11
00
44  
45 176 my $graph = _make_graph(\%params);
46 176 $graph->set_graph_attribute (name => "Bi-Star $N,$M");
47 176 ▶ my $add_edge = ($graph->is_directed ? 'add_cycle' : 'add_edge');
Branch: 1 branch
BranchTrueFalseTotal
$graph->is_directed ? : 88 88 176
48 176 my $from = 1;
49 176 foreach my $size ($N, $M) {
50 352 ▶ next unless $size;
Branch: 1 branch
BranchTrueFalseTotal
unless $size 80 272 352
51 272 $graph->add_vertex($from);
52 272 foreach my $add (1 .. $size-1) {
53 560 $graph->$add_edge($from, $from+$add);
54 }
55 272 $from += $size;
56 }
57 176 ▶ if ($N && $M) {
Branch: 1 branch
BranchTrueFalseTotal
if ($N and $M) 100 76 176
Condition100%3/3
$N and $M
!ll&&!rl&&r
4036100
MC/DC100%2/2
$N and $M
$N $M
Truth table100%3/3
A and B
A= $NB= $M
ABresult
0X0
100
111
58 100 $graph->$add_edge (1, 1+$N);
59 }
60 176 return $graph;
61 }
62  
63 1 Graph::Maker->add_factory_type('bi_star' => __PACKAGE__);
64 1 1;
65  
66 __END__
« TwindragonAreaTree.pm ↑ Summary Catalans.pm »