line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2015, 2016, 2017 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
|
|
|
|
|
|
|
# . |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package Graph::Maker::Beineke; |
20
|
1
|
|
|
1
|
|
833
|
use 5.004; |
|
1
|
|
|
|
|
3
|
|
21
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
22
|
1
|
|
|
1
|
|
8
|
use Carp 'croak'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
23
|
1
|
|
|
1
|
|
106
|
use Graph::Maker; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Graph::Maker::Star; |
25
|
|
|
|
|
|
|
use Graph::Maker::Wheel; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use vars '$VERSION','@ISA'; |
28
|
|
|
|
|
|
|
$VERSION = 7; |
29
|
|
|
|
|
|
|
@ISA = ('Graph::Maker'); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
33
|
|
|
|
|
|
|
# use Smart::Comments; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my @G_data |
36
|
|
|
|
|
|
|
= (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-----+ |
145
|
|
|
|
|
|
|
# / \ | |
146
|
|
|
|
|
|
|
# 3---1---6 |
147
|
|
|
|
|
|
|
# \ / | |
148
|
|
|
|
|
|
|
# 4-----5 |
149
|
|
|
|
|
|
|
# https://hog.grinvin.org/ViewGraphInfo.action?id=204 |
150
|
|
|
|
|
|
|
); |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub _default_graph_maker { |
153
|
|
|
|
|
|
|
require Graph; |
154
|
|
|
|
|
|
|
return Graph->new(@_); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
sub _make_graph { |
157
|
|
|
|
|
|
|
my ($params) = @_; |
158
|
|
|
|
|
|
|
my $graph_maker = delete($params->{'graph_maker'}) || \&_default_graph_maker; |
159
|
|
|
|
|
|
|
return $graph_maker->(%$params); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub init { |
163
|
|
|
|
|
|
|
my ($self, %params) = @_; |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
my $G = delete($params{'G'}) || 0; |
166
|
|
|
|
|
|
|
### $G |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
my $graph; |
169
|
|
|
|
|
|
|
if ($G == 1) { |
170
|
|
|
|
|
|
|
# G1 = claw = star-4 |
171
|
|
|
|
|
|
|
# https://hog.grinvin.org/ViewGraphInfo.action?id=204 |
172
|
|
|
|
|
|
|
# |
173
|
|
|
|
|
|
|
$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
|
|
|
|
|
|
|
$graph = Graph::Maker->new('wheel', N=>6, %params); |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
} else { |
187
|
|
|
|
|
|
|
my $edge_aref = $G_data[$G] |
188
|
|
|
|
|
|
|
|| croak "Unrecognised G: ", $G; |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
$graph = _make_graph(\%params); |
191
|
|
|
|
|
|
|
$graph->add_edges(@$edge_aref); |
192
|
|
|
|
|
|
|
if ($graph->is_directed) { |
193
|
|
|
|
|
|
|
$graph->add_edges(map {[reverse @$_]} @$edge_aref->edges); |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# override possible name from star or wheel |
198
|
|
|
|
|
|
|
$graph->set_graph_attribute (name => "Beineke G$G"); |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
return $graph; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Graph::Maker->add_factory_type('Beineke' => __PACKAGE__); |
204
|
|
|
|
|
|
|
1; |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
__END__ |