Crown.pm

filter: Statementstmt 100% 32 / 32 Branchbran 100% 4 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 93.6% 44 / 47 CC 6 SCAR 10.4
CC
6
Cov
97%
init
5.0
_make_graph
2.0
BEGIN
1.0
CRAP 2.8
« FoldedHypercube.pm ↑ Summary
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::Crown;
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 44 ▶sub _default_graph_maker {
Subroutine _default_graph_maker: called CC=1 SCAR=0.0
31 44 require Graph;
32 44 Graph->new(@_);
33 }
34 44 ▶sub _make_graph {
Subroutine _make_graph: called CC=2 SCAR=7.1
35 44 my ($params) = @_;
36 44 ▶ my $graph_maker = delete($params->{'graph_maker'}) || \&_default_graph_maker;
Condition50%1/2
delete $params->{'graph_maker'} || \&Graph::Maker::Crown::_default_graph_maker
l!l
044
MC/DC0%0/1
delete $params->{'graph_maker'} || \&Graph::Maker::Crown::_default_graph_maker
delete $params->{'graph_maker'}
Truth table50%1/2
A
A= delete $params->{'graph_maker'}
Aresult
11
00
37 44 return $graph_maker->(%$params);
38 }
39  
40 44 ▶sub init {
Subroutine init: called CC=5 SCAR=16.1
Pod undocumented
41 44 my ($self, %params) = @_;
42  
43 44 my $N = delete $params{'N'};
44 44 my $graph = _make_graph(\%params);
45 44 $graph->set_graph_attribute (name => "Crown $N");
46  
47 44 ▶ my $add_edge = ($graph->is_directed ? 'add_cycle' : 'add_edge');
Branch: 1 branch
BranchTrueFalseTotal
$graph->is_directed ? : 22 22 44
48 44 foreach my $u (1 .. $N) {
49 220 $graph->add_vertex ($u);
50 220 $graph->add_vertex ($u+$N);
51 220 foreach my $v (1 .. $N) {
52 1540 ▶ if ($u != $v) {
Branch: 1 branch
BranchTrueFalseTotal
if ($u != $v) 1320 220 1540
53 1320 $graph->$add_edge($u, $v+$N);
54 }
55 }
56 }
57 44 return $graph;
58 }
59  
60 1 Graph::Maker->add_factory_type('crown' => __PACKAGE__);
61 1 1;
62  
63 __END__
« FoldedHypercube.pm ↑ Summary