Initial commit

This commit is contained in:
hal8174 2024-11-09 20:33:25 +01:00
commit 68bfda7077
13 changed files with 4952 additions and 0 deletions

237
vertex_cover/Cargo.lock generated Normal file
View file

@ -0,0 +1,237 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "anstream"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
[[package]]
name = "anstyle-parse"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
dependencies = [
"windows-sys",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125"
dependencies = [
"anstyle",
"windows-sys",
]
[[package]]
name = "clap"
version = "4.5.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
[[package]]
name = "colorchoice"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "proc-macro2"
version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
dependencies = [
"proc-macro2",
]
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "2.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "vertex_cover"
version = "0.1.0"
dependencies = [
"clap",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"

7
vertex_cover/Cargo.toml Normal file
View file

@ -0,0 +1,7 @@
[package]
name = "vertex_cover"
version = "0.1.0"
edition = "2021"
[dependencies]
clap = { version = "4.5.20", features = ["derive"] }

176
vertex_cover/graph0.in Normal file
View file

@ -0,0 +1,176 @@
50 175
24 30
39 46
11 28
28 41
7 25
31 44
12 31
34 35
17 25
3 7
19 40
10 18
17 23
13 20
34 36
7 41
18 35
29 30
3 23
22 48
6 23
2 47
8 38
7 22
22 42
35 46
17 18
16 38
31 38
2 28
34 41
25 44
12 50
26 43
39 42
5 27
10 29
29 40
31 37
14 50
24 46
14 33
15 43
43 46
25 47
15 36
13 41
4 37
28 42
8 32
40 42
4 48
29 43
12 24
17 24
9 50
20 44
23 49
14 19
21 33
24 28
45 47
27 44
13 19
16 45
4 11
9 13
17 40
5 10
19 38
1 47
32 49
6 20
28 33
10 20
8 39
27 43
30 36
11 25
1 30
22 30
3 15
2 29
23 31
12 32
36 37
2 8
14 26
21 39
5 23
8 36
32 33
5 36
35 44
6 43
42 44
15 42
37 46
19 47
18 38
21 48
12 48
3 16
26 45
27 32
34 50
6 33
13 15
1 4
14 44
30 49
2 3
11 50
35 49
8 26
9 27
4 40
20 24
21 29
1 18
33 37
16 27
6 34
17 26
3 4
18 33
12 47
11 49
25 36
14 30
9 22
39 50
5 19
45 49
16 21
9 37
16 24
32 40
13 21
11 38
3 14
6 47
7 46
11 43
2 9
29 31
26 41
8 20
13 49
2 35
1 41
15 18
6 22
22 38
9 17
7 10
23 39
7 32
5 48
34 40
42 45
37 45
19 46
10 50
1 39
5 28
4 20
21 25
12 15
31 41
10 45
1 27
16 34
35 48
26 48

300
vertex_cover/graph1.in Normal file
View file

@ -0,0 +1,300 @@
300 299
121 131
202 119
242 181
265 20
300 63
217 23
80 234
69 55
277 73
167 217
230 247
240 208
298 26
2 246
207 65
112 153
291 141
260 271
169 81
62 90
5 228
209 135
18 92
37 180
258 144
43 81
270 38
73 92
83 220
106 38
297 74
39 9
43 252
7 63
233 9
212 209
137 50
185 84
251 113
206 140
295 225
241 17
222 4
209 72
162 274
183 143
42 199
242 104
110 119
125 112
69 173
35 114
284 260
105 95
255 264
104 147
20 174
56 32
225 142
16 287
104 284
218 277
63 11
4 192
40 134
243 127
248 24
244 134
175 99
235 276
204 89
195 168
58 4
134 175
113 236
25 27
223 212
176 182
12 266
140 188
249 82
202 90
76 189
283 233
200 250
103 295
272 296
140 45
53 26
209 23
27 78
150 135
3 300
139 223
257 224
3 148
30 107
74 156
213 169
221 258
33 199
205 147
203 229
136 50
60 287
130 290
5 145
110 158
212 220
38 92
285 241
251 187
172 85
146 186
197 231
34 210
23 86
74 143
71 5
149 295
27 24
56 225
199 93
245 80
77 104
69 38
28 244
152 40
92 119
162 124
177 93
5 138
104 92
254 18
193 131
166 284
27 151
85 219
191 44
227 212
212 232
142 129
165 295
87 279
178 284
216 90
155 166
117 285
38 212
160 162
44 5
265 289
82 73
92 3
170 123
69 130
179 124
195 100
176 37
218 75
3 50
149 196
182 159
170 157
124 273
288 212
91 162
189 102
64 220
23 108
70 177
173 6
8 189
219 104
265 49
83 12
249 238
190 109
256 280
74 34
114 59
189 10
26 115
133 79
80 128
235 18
92 97
9 80
154 138
262 279
199 239
86 253
67 57
112 91
116 275
47 173
299 37
76 65
143 197
260 120
97 286
36 173
199 226
257 192
74 285
70 203
98 73
18 21
293 233
126 152
3 162
170 93
271 263
88 258
242 169
179 20
113 237
161 192
175 14
262 45
264 267
111 272
211 83
19 104
185 31
275 198
249 66
141 234
65 193
247 79
47 68
258 240
213 281
105 132
209 101
280 65
98 204
92 109
296 22
214 44
203 278
7 51
143 115
259 73
144 54
184 60
243 282
299 286
268 26
60 104
30 294
82 52
261 215
41 188
295 140
147 122
209 282
93 104
29 184
66 1
209 164
2 131
171 106
46 219
200 69
243 215
186 280
193 113
292 131
27 189
225 97
272 286
207 105
78 275
94 173
69 118
193 48
39 168
119 15
80 3
44 74
18 257
65 59
201 111
244 162
118 133
194 276
65 97
269 162
18 67
30 257
163 258
96 286
13 123
124 84
280 255
285 258
119 74
61 8

398
vertex_cover/graph2.in Normal file
View file

@ -0,0 +1,398 @@
200 397
157 99
18 69
133 129
74 126
38 132
81 60
37 3
100 77
107 65
107 135
194 139
189 131
61 107
174 21
37 5
87 20
86 57
63 60
99 88
198 150
157 53
57 108
28 121
85 10
86 165
121 29
121 48
115 20
162 69
62 147
49 37
78 152
132 99
53 11
102 132
188 158
98 110
195 69
74 61
195 140
200 72
31 91
60 11
23 164
107 52
49 3
59 57
90 175
116 117
69 167
91 131
41 130
3 181
106 152
155 38
181 89
40 117
176 88
7 48
82 28
12 17
168 98
79 180
82 116
9 16
34 191
68 178
95 94
78 92
161 45
17 153
182 171
195 41
3 91
2 30
155 57
40 15
17 117
96 67
22 26
79 6
88 20
139 102
115 149
167 115
13 182
106 59
106 65
108 199
30 127
100 132
149 1
145 161
109 80
81 182
25 28
11 90
172 86
55 99
60 123
180 23
49 190
190 14
44 181
95 91
113 5
101 189
137 105
114 100
69 187
44 158
138 134
91 157
199 61
28 191
67 181
72 144
144 80
33 55
151 110
37 189
158 19
42 110
18 61
196 104
1 163
117 41
73 59
105 174
50 81
103 197
118 47
170 98
90 141
5 57
19 42
123 195
184 99
54 124
87 189
138 147
31 165
49 65
27 57
107 110
71 86
4 114
157 70
19 150
33 138
20 107
2 59
168 199
40 157
20 193
11 26
67 52
60 49
199 15
180 195
98 124
136 57
22 175
81 61
106 9
62 157
107 12
189 133
60 196
108 104
145 112
46 166
13 92
33 200
186 97
177 65
17 174
19 199
17 121
185 51
105 31
65 196
84 23
81 31
79 70
20 144
167 125
81 171
189 197
63 57
156 57
102 58
144 62
57 173
51 167
32 176
64 91
83 138
153 93
108 20
179 135
56 77
62 89
6 20
108 65
198 57
162 86
132 56
138 65
113 49
49 9
99 145
141 139
157 4
177 181
100 61
112 71
91 15
120 134
180 143
194 129
183 37
26 178
33 150
172 60
61 169
129 76
140 1
119 190
110 155
136 165
110 182
68 126
174 124
166 157
127 129
173 135
178 15
47 19
75 8
26 110
107 69
66 130
34 140
178 95
11 163
29 33
83 182
182 160
183 118
95 111
144 100
19 170
24 96
51 169
7 8
95 180
19 61
184 146
174 66
122 143
114 104
57 17
153 61
154 37
50 138
63 122
39 153
181 66
156 65
100 159
64 43
86 167
61 65
47 22
37 13
188 190
37 9
48 115
93 35
111 78
149 75
176 193
33 160
151 148
189 36
157 49
110 100
26 68
27 26
60 161
160 166
7 11
129 100
49 108
144 129
3 139
135 186
120 178
60 61
189 26
14 63
193 10
189 145
108 151
61 49
84 99
43 17
36 109
164 179
75 157
168 90
50 21
76 39
142 91
114 82
124 94
118 153
190 172
85 9
35 170
86 104
37 65
46 113
139 22
80 169
16 73
11 176
85 182
97 194
10 112
17 26
142 88
9 110
125 89
76 144
82 199
114 25
26 179
107 174
179 95
74 7
129 140
101 41
88 138
100 154
194 24
33 93
50 34
148 133
66 96
158 20
176 111
4 192
181 69
32 180
30 22
52 33
61 128
57 9
100 99
108 192
54 165
66 73
189 78
163 26
185 196
49 103
9 58
124 187
64 19
86 69
109 66
9 140
170 120
52 11
157 100
142 164
98 139
9 72
53 122
73 184
185 186
184 137
119 20
139 65
60 7
83 146
3 11
46 128
169 99
56 3
45 96
98 2
19 197
173 159
79 132

255
vertex_cover/graph3.in Normal file
View file

@ -0,0 +1,255 @@
136 254
47 109
39 59
3 52
77 101
16 130
33 111
28 111
34 118
111 132
25 136
42 124
133 136
86 126
62 123
34 80
109 117
49 83
122 123
16 112
18 56
53 130
39 135
41 74
56 88
24 76
21 81
28 108
56 117
91 131
66 113
71 78
27 121
110 135
38 96
63 111
105 106
34 64
1 101
79 136
5 21
44 61
2 47
83 106
38 122
90 115
69 129
76 99
81 134
77 120
44 91
86 113
3 74
4 26
36 122
76 87
95 97
6 39
10 42
76 96
84 120
56 69
26 73
23 84
59 135
3 73
3 28
9 113
87 96
62 127
42 119
123 127
67 112
25 98
46 52
48 113
104 110
76 84
23 112
22 86
95 100
11 72
2 85
6 32
19 69
102 116
9 61
52 74
51 77
101 123
15 132
30 114
18 97
55 83
26 116
35 86
77 88
30 67
13 57
12 76
68 113
32 39
5 83
105 112
36 85
42 128
33 43
58 83
42 99
75 76
68 93
108 111
48 101
20 54
119 124
133 135
68 123
10 82
38 116
40 83
48 123
79 104
58 106
81 90
107 111
10 99
18 77
60 63
49 70
89 100
40 55
20 117
1 77
17 43
23 93
36 123
113 127
56 109
12 75
75 111
38 58
5 23
9 44
31 43
39 78
11 81
95 125
63 75
81 106
5 49
17 33
51 57
45 83
8 134
7 14
22 34
35 109
7 129
58 96
21 23
69 88
23 105
24 57
48 91
50 82
72 81
3 71
70 76
15 111
73 103
26 46
65 76
29 51
12 77
18 120
16 67
37 70
39 71
12 88
13 71
43 78
67 134
27 136
2 66
121 136
19 129
63 94
1 65
26 52
110 133
60 94
89 95
24 103
37 76
80 118
21 134
33 107
22 64
116 122
8 67
81 115
87 133
29 93
1 76
84 99
17 42
24 51
31 78
3 65
113 126
66 127
14 129
45 92
26 107
4 108
37 79
62 74
56 97
3 103
79 110
26 102
57 118
23 120
37 136
35 47
83 92
81 105
3 13
23 29
87 136
10 50
67 114
73 107
28 65
29 77
9 68
97 125
38 49
26 108
44 131
2 36
22 35
13 118
38 70
98 136
76 103
17 128
8 53
91 113
41 62
16 53
59 104
39 104
54 117
93 123

521
vertex_cover/graph4.in Normal file
View file

@ -0,0 +1,521 @@
100 520
64 40
2 86
42 45
46 48
52 95
56 64
65 13
1 62
14 13
43 94
8 23
59 6
50 59
32 68
88 84
65 20
80 16
8 41
31 51
94 7
52 18
64 67
43 63
18 12
66 44
22 77
15 39
96 55
48 86
44 56
26 57
40 24
52 78
11 25
18 2
69 75
85 19
14 30
25 2
8 32
5 34
59 29
59 92
63 9
21 25
86 43
32 3
73 1
52 73
24 30
40 14
76 35
93 61
39 44
90 77
48 76
18 23
81 98
52 2
25 44
54 53
51 76
95 38
29 88
29 58
24 25
1 36
98 89
26 53
78 99
17 89
96 75
41 11
34 30
94 40
32 39
72 91
10 68
22 76
68 40
11 27
53 11
42 1
81 89
29 75
88 61
35 38
44 54
36 16
66 16
43 56
19 59
37 21
67 45
82 92
56 38
58 19
2 5
69 37
95 41
52 17
43 4
15 44
35 89
66 4
44 98
51 44
68 99
23 44
28 85
80 69
95 31
94 17
51 81
20 95
100 11
73 87
86 8
75 93
76 68
34 90
33 61
2 10
96 6
48 1
51 39
78 65
47 28
39 82
74 30
79 23
22 66
14 28
54 93
56 92
97 6
19 54
39 38
38 17
62 40
40 61
61 24
33 25
59 55
35 95
38 86
78 31
73 65
39 75
43 74
82 79
68 97
41 91
18 9
42 15
96 87
31 94
27 10
69 96
32 81
82 41
51 93
92 83
59 48
2 61
85 14
26 96
66 93
76 97
29 93
8 63
89 4
41 100
25 70
10 22
54 81
93 2
69 38
18 70
62 31
57 34
41 74
13 86
4 84
79 21
62 34
21 84
5 46
66 39
20 71
30 17
7 92
5 13
44 71
67 8
61 6
15 88
76 26
73 79
74 35
43 39
40 20
98 41
32 52
17 48
82 75
93 1
47 64
14 76
22 19
24 38
65 58
8 56
12 10
21 18
6 70
55 8
86 74
90 12
98 39
73 26
73 95
59 3
90 44
40 8
51 46
72 93
63 85
11 30
90 85
69 1
58 63
56 70
47 57
13 27
20 25
97 66
7 70
50 41
39 13
3 98
59 7
36 91
61 51
92 55
12 71
92 3
11 12
88 91
23 78
11 51
100 90
49 14
49 86
94 3
2 9
51 100
43 72
60 20
19 14
2 41
55 67
90 17
70 67
57 92
39 48
78 67
3 9
35 22
67 26
36 21
43 14
11 10
91 33
28 59
66 87
62 27
92 36
63 16
17 20
50 44
37 10
72 35
4 71
29 39
53 82
87 56
63 100
74 45
88 30
53 19
24 69
15 79
94 97
62 97
47 74
35 75
33 4
39 2
5 14
82 6
56 53
48 55
39 5
92 22
88 62
91 68
49 87
5 40
87 34
50 19
5 65
71 54
72 81
4 27
95 19
30 100
23 33
31 14
62 78
47 60
29 99
85 23
19 28
6 45
53 28
51 57
5 86
57 53
14 35
5 42
24 31
43 68
72 68
67 35
36 60
22 28
59 12
32 53
5 28
33 45
67 59
68 86
84 30
25 39
85 13
28 56
84 92
58 66
94 61
99 36
74 17
74 32
91 89
15 63
41 32
69 49
40 85
83 28
44 93
31 26
5 29
23 93
35 20
66 11
30 53
41 4
100 72
24 87
39 57
33 65
7 36
54 50
20 85
51 45
20 89
38 49
55 62
51 86
12 72
43 60
84 41
39 41
64 26
57 100
34 33
50 84
24 95
39 88
2 82
12 70
44 73
80 49
24 15
46 56
100 25
24 83
85 41
25 77
86 3
64 44
96 81
71 6
55 100
22 6
48 43
28 25
7 9
58 44
25 54
25 5
24 34
55 76
88 9
41 26
83 79
52 42
38 63
10 98
60 81
61 38
70 100
29 19
72 1
12 46
67 96
98 61
80 82
89 7
46 100
93 82
97 88
29 44
25 16
25 53
68 20
10 96
95 34
16 44
95 79
3 50
83 34
91 76
88 57
32 6
38 57
59 61
62 15
11 52
96 59
7 79
30 9
1 92
67 23
33 11
97 54
61 39
62 38
4 38
48 44
54 18
41 65
40 97
10 15
72 85
15 58
98 31
42 60
51 19
72 10
90 28
45 84
96 61
66 67
12 74
81 1
93 21
74 20
22 71
61 22
31 77
21 43
26 23
54 14
40 77
64 52
4 67
20 82
12 80
83 71
42 31
1 12
33 77
3 70
46 65
11 14
16 31
50 4
54 67
1 68
50 31
58 60
95 10
88 80
96 27
93 64
13 30
46 82
13 79
84 78
41 61
25 38
22 8
60 45
37 63
33 63
41 12
12 87
71 1
9 13

2114
vertex_cover/graph5.in Normal file

File diff suppressed because it is too large Load diff

670
vertex_cover/graph6.in Normal file
View file

@ -0,0 +1,670 @@
177 669
15 172
68 138
54 153
32 54
3 35
131 149
1 64
49 78
65 84
113 114
20 109
41 160
74 94
47 119
43 63
8 107
76 88
32 113
70 162
23 97
13 20
74 139
115 144
65 154
26 54
35 65
61 107
94 132
119 132
84 154
8 12
131 160
37 44
97 168
26 109
17 176
58 110
62 143
109 144
115 153
80 85
84 102
101 150
28 154
71 93
100 129
74 156
94 143
118 152
21 129
24 80
25 70
116 138
59 145
122 177
20 115
113 155
17 50
35 152
51 157
6 92
51 100
21 99
86 147
26 30
50 51
42 84
99 169
32 101
35 105
10 125
96 130
98 115
60 93
142 153
53 151
22 175
28 143
98 109
143 168
40 168
33 60
6 27
14 107
60 145
36 37
63 164
14 141
5 79
13 136
26 144
159 171
12 20
67 109
117 123
89 152
77 133
21 169
96 102
124 148
67 115
19 32
22 63
36 70
70 127
117 157
110 166
72 94
40 62
4 76
36 44
94 165
109 115
38 177
11 50
17 155
80 135
37 168
55 82
44 58
32 115
80 157
54 110
24 153
30 106
50 63
24 54
55 102
68 94
18 84
65 152
55 133
84 89
44 110
127 146
19 176
78 147
71 102
18 110
137 150
56 153
94 138
8 40
19 150
153 175
29 35
43 153
51 85
28 81
17 156
24 113
75 95
51 123
8 20
17 63
29 119
8 157
77 93
40 81
63 158
12 131
115 117
59 120
36 110
30 144
54 131
29 60
143 173
132 134
113 135
17 30
54 165
141 155
28 168
25 110
113 153
39 170
4 88
108 119
15 110
107 147
40 88
54 120
57 127
17 74
84 111
30 155
71 84
124 159
52 172
1 56
66 102
80 100
26 32
98 107
9 87
33 50
107 114
104 112
69 168
12 34
39 163
36 168
20 98
26 125
27 121
11 63
54 115
13 61
19 86
60 120
66 71
35 118
5 113
71 77
16 119
56 174
93 119
2 54
91 107
124 140
80 113
2 80
131 153
14 112
19 147
119 139
54 80
63 175
28 84
60 128
3 90
52 110
26 153
81 168
1 153
61 147
12 13
13 153
60 119
16 72
26 131
35 127
46 79
11 155
12 107
126 153
8 91
76 151
36 97
49 143
94 102
71 96
5 46
32 176
20 147
4 53
155 159
23 166
81 143
32 150
60 159
104 141
157 169
122 156
3 105
83 131
2 153
155 171
158 164
92 115
12 98
96 143
127 133
1 174
52 167
3 156
115 131
45 93
131 135
77 96
33 63
72 78
30 33
32 173
79 161
35 156
7 63
13 40
32 131
119 173
53 120
8 99
20 67
40 96
18 94
21 51
15 173
53 54
132 143
38 127
28 40
41 159
74 119
30 50
42 156
23 146
44 168
35 133
2 113
113 115
63 142
33 155
54 113
105 156
149 163
8 147
32 86
62 96
84 94
75 131
40 147
172 177
43 142
54 60
80 115
35 47
119 133
34 147
73 84
51 80
34 40
148 159
17 32
106 115
20 107
58 162
17 159
41 170
110 127
23 127
58 97
16 74
137 176
24 131
31 130
24 32
9 71
28 62
43 126
91 147
30 60
38 172
75 83
12 40
108 116
31 71
55 93
45 48
64 75
115 121
50 171
30 123
12 149
49 134
113 161
56 164
46 155
2 32
54 135
50 159
38 122
102 110
59 151
107 113
72 173
17 137
40 54
12 39
82 133
77 82
12 61
35 111
127 166
42 94
40 98
70 168
67 106
62 130
30 159
119 122
17 122
13 107
97 127
20 26
114 141
71 110
72 119
30 46
54 59
50 123
8 169
40 61
142 175
28 89
60 133
29 127
2 131
134 173
21 80
92 121
40 143
116 119
21 157
82 93
80 117
7 17
13 126
22 43
59 60
110 168
27 92
20 144
73 90
63 171
60 63
54 84
8 13
131 163
78 94
32 147
47 127
103 114
135 153
71 133
149 170
26 106
33 125
63 159
31 102
80 169
11 159
10 115
25 57
15 42
128 145
20 40
93 102
12 91
119 156
23 162
112 155
17 150
7 159
35 60
60 155
103 107
16 173
71 130
12 163
112 113
28 69
18 54
83 124
13 142
39 159
27 30
56 64
120 128
84 110
111 118
119 127
74 132
80 99
93 127
94 119
50 100
35 84
98 106
78 134
50 157
69 143
129 157
39 160
11 60
32 135
83 140
159 170
136 153
60 127
21 85
35 119
71 82
146 167
66 96
35 93
99 157
62 71
132 139
23 57
8 34
110 167
31 55
40 69
33 159
31 93
98 147
40 107
50 60
143 147
64 158
52 177
84 90
140 148
13 98
54 151
40 151
94 139
131 159
74 122
84 165
113 141
115 161
94 173
15 122
40 76
106 144
33 144
42 173
49 94
62 168
33 115
13 147
63 153
54 102
96 168
83 95
40 120
15 52
34 107
101 147
71 94
68 108
5 161
54 128
70 110
9 45
131 170
14 103
48 93
132 173
3 73
54 71
97 166
7 60
95 131
26 115
42 73
39 131
136 142
10 30
8 98
158 174
23 110
66 77
32 94
71 87
50 129
79 155
45 87
167 172
70 97
62 66
50 155
6 30
8 61
32 42
26 80
53 88
54 94
49 72
13 34
32 153
10 144
80 131
58 127
127 162
42 90
80 153
162 166
64 153
8 85
73 105
86 101
15 32
140 159
78 143
94 134
14 113
110 165
84 152
60 171
63 174
17 33
7 50
148 158
14 155
13 91
85 157
103 113
134 143
72 132
122 146
70 167
127 177
6 121
17 119
30 115
4 40
15 94
97 110
77 102
110 172
113 131
30 63
10 33
66 130
106 125
31 62
17 60
17 171
164 174
63 155
28 96
108 138
51 129
159 160
67 98
94 110
146 177
122 127
47 60
75 148
15 167
68 116
93 133
95 124
16 139
17 19
7 155
40 53
31 77
37 58
28 65
26 113
104 155
40 91
38 146
11 17
126 136
30 125
12 147
89 154
37 110
65 111
32 80
85 100
58 70
21 50

View file

@ -0,0 +1,71 @@
use crate::Graph;
use std::collections::HashSet;
pub fn binary_edge(graph: &Graph, k: u16, v: HashSet<u16>) -> Option<HashSet<u16>> {
let edge = match graph.get_edge_filtered(&v) {
Some(edge) => edge,
None => return Some(v),
};
if k == 0 {
return None;
}
let mut v1 = v.clone();
v1.insert(edge.0);
match binary_edge(graph, k - 1, v1) {
Some(s) => Some(s),
None => {
let mut v2 = v;
v2.insert(edge.1);
binary_edge(graph, k - 1, v2)
}
}
}
pub fn binary_vertex(graph: &Graph, k: u16, v: HashSet<u16>) -> Option<HashSet<u16>> {
let vertex = match graph.get_vertex_filtered_with_degree_grater(&v, 2) {
Some(vertex) => vertex,
None => {
return {
let mut v3 = v;
let mut c = 0;
while let Some(vertex) = graph.get_vertex_filtered_with_degree_grater(&v3, 1) {
v3.insert(vertex);
c += 1;
}
if c <= k {
Some(v3)
} else {
None
}
}
}
};
if k == 0 {
return None;
}
let mut v1 = v.clone();
v1.insert(vertex);
match binary_vertex(graph, k - 1, v1) {
Some(s) => Some(s),
None => {
let mut v2 = v;
let mut c = 0;
for o in graph.get_edges(vertex) {
if !v2.contains(&o) {
c += 1;
v2.insert(o);
}
}
if c <= k {
binary_vertex(graph, k - c, v2)
} else {
None
}
}
}
}

162
vertex_cover/src/main.rs Normal file
View file

@ -0,0 +1,162 @@
use clap::{Parser, ValueEnum};
use std::{
collections::HashSet,
path::{Path, PathBuf},
};
mod filtered;
fn parse(filename: impl AsRef<Path>) -> Graph {
let content = std::fs::read_to_string(filename).unwrap();
let mut line_iter = content
.split('\n')
.map(|l| l.trim())
.filter(|l| !l.is_empty());
let first_line = line_iter.next().unwrap();
let (nodes_str, edges_str) = first_line.split_once(' ').unwrap();
let nodes = nodes_str.parse::<u16>().unwrap();
let edges = edges_str.parse::<u16>().unwrap();
let mut g = Graph::new(nodes);
let mut c = 0;
for l in line_iter {
let (from_str, to_str) = l.split_once(' ').unwrap();
let from = from_str.parse::<u16>().unwrap();
let to = to_str.parse::<u16>().unwrap();
g.add_edge(from - 1, to - 1);
c += 1;
}
assert_eq!(edges, c);
g
}
/// Datastructure is 0 indexed
#[derive(Debug)]
struct Graph {
edge_list: Vec<Vec<u16>>,
}
impl Graph {
fn new(num_vertices: u16) -> Self {
Self {
edge_list: vec![Vec::new(); num_vertices as usize],
}
}
fn add_edge(&mut self, from: u16, to: u16) {
self.edge_list[(from) as usize].push(to);
self.edge_list[(to) as usize].push(from);
}
fn get_edges(&self, vertex: u16) -> impl Iterator<Item = u16> + '_ {
self.edge_list[vertex as usize].iter().copied()
}
fn iter_edges_filtered<'a>(
&'a self,
v: &'a HashSet<u16>,
) -> impl Iterator<Item = (u16, u16)> + 'a {
self.edge_list
.iter()
.enumerate()
.filter(|(i, _)| !v.contains(&(*i as u16)))
.flat_map(move |(i, s)| {
let from = i as u16;
s.iter().filter_map(move |&to| {
if !v.contains(&to) && from < to {
Some((from, to))
} else {
None
}
})
})
}
fn get_edge_filtered(&self, v: &HashSet<u16>) -> Option<(u16, u16)> {
self.iter_edges_filtered(v).next()
}
fn iter_vertices_filtered_with_degree_grater<'a>(
&'a self,
v: &'a HashSet<u16>,
min_degree: u16,
) -> impl Iterator<Item = u16> + 'a {
self.edge_list.iter().enumerate().filter_map(move |(i, s)| {
let i = i as u16;
if !v.contains(&i) && s.iter().filter(|&o| !v.contains(o)).count() as u16 >= min_degree
{
Some(i)
} else {
None
}
})
}
fn get_vertex_filtered_with_degree_grater(
&self,
v: &HashSet<u16>,
min_degree: u16,
) -> Option<u16> {
self.iter_vertices_filtered_with_degree_grater(v, min_degree)
.next()
}
}
fn vertex_cover(graph: &Graph, k: u16, method: Method) -> Option<HashSet<u16>> {
match method {
Method::Edge => filtered::binary_edge(graph, k, HashSet::new()),
Method::Vertex => filtered::binary_vertex(graph, k, HashSet::new()),
}
}
#[derive(Debug, Clone, Copy, ValueEnum)]
enum Method {
Edge,
Vertex,
}
#[derive(Debug, Parser)]
struct Args {
filename: PathBuf,
method: Method,
k: Option<u16>,
}
fn main() {
let args = Args::parse();
let graph = parse(args.filename);
let result = if let Some(k) = args.k {
let start = std::time::Instant::now();
let r = vertex_cover(&graph, k, args.method);
eprintln!("{}: {:?}", k, start.elapsed());
r
} else {
let mut k = 0;
loop {
let start = std::time::Instant::now();
let r = vertex_cover(&graph, k, args.method);
eprintln!("{}: {:?}", k, start.elapsed());
if let Some(r) = r {
break Some(r);
}
k += 1;
}
};
if let Some(solution) = result {
println!("{}", solution.len());
for n in solution {
println!("{}", n + 1);
}
}
}

37
vertex_cover/validator.py Executable file
View file

@ -0,0 +1,37 @@
#!/usr/bin/env python3
"""
usage: python3 validator.py path/to/graph path/to/vertex/cover
"""
import sys
graph = sys.argv[1]
graph_file = open(graph, "r")
sol = sys.argv[2]
sol_file = open(sol, "r")
n, m = map(int, graph_file.readline().split())
lines = graph_file.readlines()
edges = list(map(int, l.split()) for l in lines[1:])
lines = sol_file.readlines();
vc_size = int(lines[0])
vc = set(int(s) for s in lines[1:])
if vc_size != len(vc):
print("Printed size does not match")
quit()
for v in vc:
if v < 1 or v > n:
print("ID {} not valid".format(v))
for a, b in edges:
if a not in vc and b not in vc:
print("Edge {} {} is not covered".format(a, b))
quit()
print("Valid vertex cover")