Kneser.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 4 / 4 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 90.9% 50 / 55 CC 8 SCAR 16.7
CC
8
Cov
96%
init
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.3
« BinomialBoth.pm ↑ Summary HalvedHypercube.pm »
1 # Copyright 2015, 2016, 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 package Graph::Maker::Kneser;
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  
24 1 ▶use vars '$VERSION','@ISA';
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 $VERSION = 19;
26 1 @ISA = ('Graph::Maker');
27  
28 # uncomment this to run the ### lines
29 # use Smart::Comments;
30  
31 1 ▶use Graph::Maker::Johnson;
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 36 ▶sub init {
Subroutine init: called CC=8 SCAR=20.8
Pod undocumented
34 36 my ($self, %params) = @_;
35  
36 36 ▶ my $N = delete($params{'N'}) || 0;
Condition50%1/2
delete $params{'N'} || 0
l!l
360
MC/DC0%0/1
delete $params{'N'} || 0
delete $params{'N'}
Truth table50%1/2
A
A= delete $params{'N'}
Aresult
11
00
37 36 ▶ my $K = delete($params{'K'}) || 0;
Condition50%1/2
delete $params{'K'} || 0
l!l
360
MC/DC0%0/1
delete $params{'K'} || 0
delete $params{'K'}
Truth table50%1/2
A
A= delete $params{'K'}
Aresult
11
00
38 ### $N
39 ### $K
40 36 my $graph = Graph::Maker::Johnson::_make_graph(\%params);
41  
42 36 $graph->set_graph_attribute (name => "Kneser $N,$K");
43 36 my $directed = $graph->is_directed;
44  
45 36 my @vertices = Graph::Maker::Johnson::_N_K_subsets($N,$K);
46 36 foreach my $v (@vertices) {
47 193 $graph->add_vertex(join(',',@$v));
48 }
49  
50 36 ▶ my $add_edge = ($graph->is_directed ? 'add_cycle' : 'add_edge');
Branch: 1 branch
BranchTrueFalseTotal
$graph->is_directed ? : 26 10 36
51 36 foreach my $i_from (0 .. $#vertices-1) {
52 157 my $from = $vertices[$i_from];
53 157 foreach my $i_to ($i_from+1 .. $#vertices) {
54 1150 my $to = $vertices[$i_to];
55 ### consider: "from=".join(',',@$from)." to=".join(',',@$to)
56  
57 1150 my $count = Graph::Maker::Johnson::_sorted_arefs_count_same($from, $to);
58 ### $count
59 1150 ▶ if ($count == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count == 0) 140 1010 1150
60 140 my $v_from = join(',',@$from);
61 140 my $v_to = join(',',@$to);
62 ### edge: "$v_from to $v_to"
63 140 $graph->$add_edge($v_from, $v_to);
64 }
65 }
66 }
67 36 return $graph;
68 }
69  
70 1 Graph::Maker->add_factory_type('Kneser' => __PACKAGE__);
71 1 1;
72  
73 __END__
« BinomialBoth.pm ↑ Summary HalvedHypercube.pm »