| 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
MC/DC0%0/1
delete $params{'N'} || 0
delete $params{'N'}
Truth table50%1/2
A
A= delete $params{'N'}
| |||||||||||||
| 37 | 36 | ▶ | my $K = delete($params{'K'}) || 0; | ||||||||||
|
Condition50%1/2
delete $params{'K'} || 0
MC/DC0%0/1
delete $params{'K'} || 0
delete $params{'K'}
Truth table50%1/2
A
A= delete $params{'K'}
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 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__ | ||||||||||||