Circulant.pm

filter: Statementstmt 100% 41 / 41 Branchbran 83.3% 5 / 6 Conditioncond 57.1% 4 / 7 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 88.0% 59 / 67 CC 9 SCAR 15.4
CC
9
Cov
93%
init
8.1
_make_graph
2.0
BEGIN
1.0
CRAP 4.7
« Johnson.pm ↑ Summary ExcessConfigurations.pm »
1 # Copyright 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 package Graph::Maker::Circulant;
20 1 ▶use 5.004;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use Graph::Maker;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use List::Util 'min';
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 14 ▶sub _default_graph_maker {
Subroutine _default_graph_maker: called CC=1 SCAR=0.0
31 14 require Graph;
32 14 return Graph->new(@_);
33 }
34 14 ▶sub _make_graph {
Subroutine _make_graph: called CC=2 SCAR=7.1
35 14 my ($params) = @_;
36 14 ▶ my $graph_maker = delete($params->{'graph_maker'}) || \&_default_graph_maker;
Condition50%1/2
delete $params->{'graph_maker'} || \&Graph::Maker::Circulant::_default_graph_maker
l!l
014
MC/DC0%0/1
delete $params->{'graph_maker'} || \&Graph::Maker::Circulant::_default_graph_maker
delete $params->{'graph_maker'}
Truth table50%1/2
A
A= delete $params->{'graph_maker'}
Aresult
11
00
37 14 return $graph_maker->(%$params);
38 }
39  
40 14 ▶sub init {
Subroutine init: called CC=8 SCAR=20.9
Pod undocumented
41 14 my ($self, %params) = @_;
42  
43 14 ▶ my $N = delete($params{'N'}) || 0;
Condition50%1/2
delete $params{'N'} || 0
l!l
140
MC/DC0%0/1
delete $params{'N'} || 0
delete $params{'N'}
Truth table50%1/2
A
A= delete $params{'N'}
Aresult
11
00
44 14 my $offset_list = delete($params{'offset_list'});
45 14 my $graph = _make_graph(\%params);
46 14 $graph->set_graph_attribute
47 (name => "Circulant $N Offset ".join(',',@$offset_list));
48  
49 14 my $directed = $graph->is_directed;
50 14 $graph->add_vertices(1 .. $N);
51 14 my %seen;
52 14 my $half = $N/2;
53 14 foreach my $o (@$offset_list) {
54 17 my $o = min($o%$N, (-$o)%$N);
55 17 ▶ next if $seen{$o}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$o}++ 0 17 17
56 17 ▶ foreach my $from (1 .. ($o==$half ? $half : $N)) {
Branch: 1 branch
BranchTrueFalseTotal
$o == $half ? : 4 13 17
57 61 my $to = ($from + $o - 1) % $N + 1; # 1 to N modulo
58 61 $graph->add_edge($from,$to);
59 61 ▶ if ($directed && $o) { $graph->add_edge($to,$from); }
Branch: 1 branch
BranchTrueFalseTotal
if ($directed and $o) 54 7 61
Condition66%2/3
$directed and $o
!ll&&!rl&&r
0754
MC/DC50%1/2
$directed and $o
$directed $o
Truth table66%2/3
A and B
A= $directedB= $o
ABresult
0X0
100
111
60 }
61 }
62 14 return $graph;
63 }
64  
65 1 Graph::Maker->add_factory_type('circulant' => __PACKAGE__);
66 1 1;
67  
68 __END__
« Johnson.pm ↑ Summary ExcessConfigurations.pm »