| 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::Beineke; | ||||||||||||||
| 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 Carp 'croak'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 23 | 1 | ▶ | use Graph::Maker; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 24 | 1 | ▶ | use Graph::Maker::Star; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 25 | 1 | ▶ | use Graph::Maker::Wheel; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 26 | |||||||||||||||
| 27 | 1 | ▶ | use vars '$VERSION','@ISA'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 28 | 1 | $VERSION = 19; | |||||||||||||
| 29 | 1 | @ISA = ('Graph::Maker'); | |||||||||||||
| 30 | |||||||||||||||
| 31 | |||||||||||||||
| 32 | # uncomment this to run the ### lines | ||||||||||||||
| 33 | # use Smart::Comments; | ||||||||||||||
| 34 | |||||||||||||||
| 35 | my @G_data | ||||||||||||||
| 36 | 1 | = (undef, # 0 | |||||||||||||
| 37 | undef, # 1 | ||||||||||||||
| 38 | [ | ||||||||||||||
| 39 | # G2 2-----+ | ||||||||||||||
| 40 | # / \ | | ||||||||||||||
| 41 | # 3---1 5 | ||||||||||||||
| 42 | # \ / | | ||||||||||||||
| 43 | # 4-----+ | ||||||||||||||
| 44 | # https://hog.grinvin.org/ViewGraphInfo.action?id=438 | ||||||||||||||
| 45 | [1,2],[1,3],[1,4], | ||||||||||||||
| 46 | [2,3],[2,5], | ||||||||||||||
| 47 | [3,4], | ||||||||||||||
| 48 | [4,5], | ||||||||||||||
| 49 | ], | ||||||||||||||
| 50 | [ | ||||||||||||||
| 51 | # G3 = K5-e complete 5 less one edge | ||||||||||||||
| 52 | # 1 | ||||||||||||||
| 53 | # /|\ +----2-----+ | ||||||||||||||
| 54 | # / 2 \ | / \ | | ||||||||||||||
| 55 | # / /|\ \ | 3---1---5 | ||||||||||||||
| 56 | # / / 3 \ \ | \ / | | ||||||||||||||
| 57 | # |/ / \ \ | +----4-----+ | ||||||||||||||
| 58 | # 4--------5 | ||||||||||||||
| 59 | # https://hog.grinvin.org/ViewGraphInfo.action?id=450 | ||||||||||||||
| 60 | # | ||||||||||||||
| 61 | [1,2],[1,3],[1,4],[1,5], | ||||||||||||||
| 62 | [2,3],[2,4],[2,5], | ||||||||||||||
| 63 | [3,4], # missing 3,5 | ||||||||||||||
| 64 | [4,5], | ||||||||||||||
| 65 | ], | ||||||||||||||
| 66 | [ | ||||||||||||||
| 67 | # G4 2----6 | ||||||||||||||
| 68 | # / \ | ||||||||||||||
| 69 | # 3---1 | ||||||||||||||
| 70 | # \ / | ||||||||||||||
| 71 | # 4----5 | ||||||||||||||
| 72 | # https://hog.grinvin.org/ViewGraphInfo.action?id=922 | ||||||||||||||
| 73 | # | ||||||||||||||
| 74 | [1,2],[1,3],[1,4], | ||||||||||||||
| 75 | [2,3],[2,6], | ||||||||||||||
| 76 | [3,4], | ||||||||||||||
| 77 | [4,5], | ||||||||||||||
| 78 | ], | ||||||||||||||
| 79 | [ | ||||||||||||||
| 80 | # G5 +----2----+ 2 | ||||||||||||||
| 81 | # | / \ | /|\ | ||||||||||||||
| 82 | # | 3---1 5--6 / 1 \ | ||||||||||||||
| 83 | # | \ / | / / \ \ | ||||||||||||||
| 84 | # +----4----+ 4-----3 | ||||||||||||||
| 85 | # \ / | ||||||||||||||
| 86 | # \ / | ||||||||||||||
| 87 | # 5----6 | ||||||||||||||
| 88 | # | ||||||||||||||
| 89 | # https://hog.grinvin.org/ViewGraphInfo.action?id=21099 | ||||||||||||||
| 90 | # | ||||||||||||||
| 91 | [1,2],[1,3],[1,4], | ||||||||||||||
| 92 | [2,3],[2,4],[2,5], | ||||||||||||||
| 93 | [3,4], | ||||||||||||||
| 94 | [4,5], | ||||||||||||||
| 95 | [5,6], | ||||||||||||||
| 96 | ], | ||||||||||||||
| 97 | [ | ||||||||||||||
| 98 | # G6 +----2--\--\ 1 | ||||||||||||||
| 99 | # | / \ \ \ /|\ | ||||||||||||||
| 100 | # | 3---1 5--6 / 3 \ | ||||||||||||||
| 101 | # | \ / / / / / \ \ | ||||||||||||||
| 102 | # +----4--/--/ 4-----2 | ||||||||||||||
| 103 | # \ \ / / | ||||||||||||||
| 104 | # \ 5 / | ||||||||||||||
| 105 | # \|/ | ||||||||||||||
| 106 | # 6 | ||||||||||||||
| 107 | # https://hog.grinvin.org/ViewGraphInfo.action?id=744 | ||||||||||||||
| 108 | # | ||||||||||||||
| 109 | [1,2],[1,3],[1,4], | ||||||||||||||
| 110 | [2,3],[2,5],[2,4],[2,6], | ||||||||||||||
| 111 | [3,4], | ||||||||||||||
| 112 | [4,5],[4,6], | ||||||||||||||
| 113 | [5,6], | ||||||||||||||
| 114 | ], | ||||||||||||||
| 115 | [ | ||||||||||||||
| 116 | # G7 2-----6 | ||||||||||||||
| 117 | # / \ | | ||||||||||||||
| 118 | # 3---1 | | ||||||||||||||
| 119 | # \ / | | ||||||||||||||
| 120 | # 4-----5 | ||||||||||||||
| 121 | # https://hog.grinvin.org/ViewGraphInfo.action?id=21093 | ||||||||||||||
| 122 | # | ||||||||||||||
| 123 | [1,2],[1,3],[1,4], | ||||||||||||||
| 124 | [2,3],[2,6], | ||||||||||||||
| 125 | [3,4], | ||||||||||||||
| 126 | [4,5], | ||||||||||||||
| 127 | [5,6], | ||||||||||||||
| 128 | ], | ||||||||||||||
| 129 | [ | ||||||||||||||
| 130 | # G8 2 3---2 | ||||||||||||||
| 131 | # / \ | / | | ||||||||||||||
| 132 | # 3--1---5 1---4 | ||||||||||||||
| 133 | # \ | / | | / | | ||||||||||||||
| 134 | # 4---6 5---6 | ||||||||||||||
| 135 | # https://hog.grinvin.org/ViewGraphInfo.action?id=21096 | ||||||||||||||
| 136 | # | ||||||||||||||
| 137 | [1,2],[1,3],[1,4],[1,5], | ||||||||||||||
| 138 | [2,3], | ||||||||||||||
| 139 | [3,4], | ||||||||||||||
| 140 | [4,5],[4,6], | ||||||||||||||
| 141 | [5,6], | ||||||||||||||
| 142 | ], | ||||||||||||||
| 143 | |||||||||||||||
| 144 | # G9 wheel 2----6 | ||||||||||||||
| 145 | # / \ / | | ||||||||||||||
| 146 | # 3---1 | | ||||||||||||||
| 147 | # \ / \ | | ||||||||||||||
| 148 | # 4----5 | ||||||||||||||
| 149 | # https://hog.grinvin.org/ViewGraphInfo.action?id=204 | ||||||||||||||
| 150 | ); | ||||||||||||||
| 151 | |||||||||||||||
| 152 | 28 | ▶ | sub _default_graph_maker { | ||||||||||||
|
Subroutine
_default_graph_maker: called CC=1 SCAR=0.0
| |||||||||||||||
| 153 | 28 | require Graph; | |||||||||||||
| 154 | 28 | return Graph->new(@_); | |||||||||||||
| 155 | } | ||||||||||||||
| 156 | 28 | ▶ | sub _make_graph { | ||||||||||||
|
Subroutine
_make_graph: called CC=2 SCAR=7.1
| |||||||||||||||
| 157 | 28 | my ($params) = @_; | |||||||||||||
| 158 | 28 | ▶ | my $graph_maker = delete($params->{'graph_maker'}) || \&_default_graph_maker; | ||||||||||||
|
Condition50%1/2
delete $params->{'graph_maker'} || \&Graph::Maker::Beineke::_default_graph_maker
MC/DC0%0/1
delete $params->{'graph_maker'} || \&Graph::Maker::Beineke::_default_graph_maker
delete $params->{'graph_maker'}
Truth table50%1/2
A
A= delete $params->{'graph_maker'}
| |||||||||||||||
| 159 | 28 | return $graph_maker->(%$params); | |||||||||||||
| 160 | } | ||||||||||||||
| 161 | |||||||||||||||
| 162 | 33 | ▶ | sub init { | ||||||||||||
|
Subroutine
init: called CC=6 SCAR=18.4
Pod
undocumented
| |||||||||||||||
| 163 | 33 | my ($self, %params) = @_; | |||||||||||||
| 164 | |||||||||||||||
| 165 | 33 | ▶ | my $G = delete($params{'G'}) || 0; | ||||||||||||
|
Condition50%1/2
delete $params{'G'} || 0
MC/DC0%0/1
delete $params{'G'} || 0
delete $params{'G'}
Truth table50%1/2
A
A= delete $params{'G'}
| |||||||||||||||
| 166 | ### $G | ||||||||||||||
| 167 | |||||||||||||||
| 168 | 33 | my $graph; | |||||||||||||
| 169 | 33 | ▶ | if ($G == 1) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 170 | # G1 = claw = star-4 | ||||||||||||||
| 171 | # https://hog.grinvin.org/ViewGraphInfo.action?id=204 | ||||||||||||||
| 172 | # | ||||||||||||||
| 173 | 2 | $graph = Graph::Maker->new('star', N=>4, %params); | |||||||||||||
| 174 | |||||||||||||||
| 175 | } elsif ($G == 9) { | ||||||||||||||
| 176 | # G9 = wheel 6 | ||||||||||||||
| 177 | # 2 6 vertices | ||||||||||||||
| 178 | # / | \ 10 edges | ||||||||||||||
| 179 | # 4---1---3 | ||||||||||||||
| 180 | # \ / \ / | ||||||||||||||
| 181 | # 5---6 | ||||||||||||||
| 182 | # https://hog.grinvin.org/ViewGraphInfo.action?id=204 | ||||||||||||||
| 183 | # | ||||||||||||||
| 184 | 3 | $graph = Graph::Maker->new('wheel', N=>6, %params); | |||||||||||||
| 185 | |||||||||||||||
| 186 | } else { | ||||||||||||||
| 187 | 28 | ▶ | my $edge_aref = $G_data[$G] | ||||||||||||
|
Condition50%1/2
$G_data[$G] || croak('Unrecognised G: ', $G)
MC/DC0%0/1
$G_data[$G] || croak('Unrecognised G: ', $G)
$G_data[$G]
Truth table50%1/2
A
A= $G_data[$G]
| |||||||||||||||
| 188 | || croak "Unrecognised G: ", $G; | ||||||||||||||
| 189 | |||||||||||||||
| 190 | 28 | $graph = _make_graph(\%params); | |||||||||||||
| 191 | 28 | $graph->add_edges(@$edge_aref); | |||||||||||||
| 192 | 28 | ▶ | if ($graph->is_directed) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 193 | 0 | $graph->add_edges(map {[reverse @$_]} @$edge_aref->edges); | |||||||||||||
| 194 | } | ||||||||||||||
| 195 | } | ||||||||||||||
| 196 | |||||||||||||||
| 197 | # override possible name from star or wheel | ||||||||||||||
| 198 | 33 | $graph->set_graph_attribute (name => "Beineke G$G"); | |||||||||||||
| 199 | |||||||||||||||
| 200 | 33 | return $graph; | |||||||||||||
| 201 | } | ||||||||||||||
| 202 | |||||||||||||||
| 203 | 1 | Graph::Maker->add_factory_type('Beineke' => __PACKAGE__); | |||||||||||||
| 204 | 1 | 1; | |||||||||||||
| 205 | |||||||||||||||
| 206 | __END__ | ||||||||||||||