Passed
Push — main ( 25fd53...ab2bda )
by Eran
02:05
created

graphs.cylinder_graph()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
import itertools
2
from collections.abc import Iterable
3
from typing import NewType
4
5
import networkx as nx
6
7
SPECIAL_GRAPHS_ADJACENCY_LISTS = {
8
    'Buckyball - Truncated Icosahedral Graph': {
9
        1: [2, 3, 4],
10
        2: [1, 55, 56],
11
        3: [1, 58, 60],
12
        4: [1, 57, 59],
13
        5: [8, 13, 14],
14
        6: [8, 12, 15],
15
        7: [8, 11, 16],
16
        8: [5, 6, 7],
17
        9: [13, 15, 25],
18
        10: [14, 16, 26],
19
        11: [7, 12, 24],
20
        12: [6, 11, 23],
21
        13: [5, 9, 18],
22
        14: [5, 10, 17],
23
        15: [6, 9, 19],
24
        16: [7, 10, 20],
25
        17: [14, 18, 30],
26
        18: [13, 17, 29],
27
        19: [15, 28, 32],
28
        20: [16, 27, 31],
29
        21: [26, 30, 46],
30
        22: [25, 29, 45],
31
        23: [12, 28, 38],
32
        24: [11, 27, 37],
33
        25: [9, 22, 32],
34
        26: [10, 21, 31],
35
        27: [20, 24, 35],
36
        28: [19, 23, 36],
37
        29: [18, 22, 43],
38
        30: [17, 21, 44],
39
        31: [20, 26, 42],
40
        32: [19, 25, 41],
41
        33: [35, 42, 53],
42
        34: [36, 41, 54],
43
        35: [27, 33, 40],
44
        36: [28, 34, 39],
45
        37: [24, 38, 40],
46
        38: [23, 37, 39],
47
        39: [36, 38, 52],
48
        40: [35, 37, 51],
49
        41: [32, 34, 50],
50
        42: [31, 33, 49],
51
        43: [29, 44, 48],
52
        44: [30, 43, 47],
53
        45: [22, 48, 50],
54
        46: [21, 47, 49],
55
        47: [44, 46, 60],
56
        48: [43, 45, 59],
57
        49: [42, 46, 58],
58
        50: [41, 45, 57],
59
        51: [40, 52, 56],
60
        52: [39, 51, 55],
61
        53: [33, 56, 58],
62
        54: [34, 55, 57],
63
        55: [2, 52, 54],
64
        56: [2, 51, 53],
65
        57: [4, 50, 54],
66
        58: [3, 49, 53],
67
        59: [4, 48, 60],
68
        60: [3, 47, 59]
69
    },
70
    'D30 - Rhombic Triacontahedral Graph': {
71
        1: [21, 22, 23],
72
        2: [24, 27, 30],
73
        3: [24, 29, 30],
74
        4: [26, 29, 32],
75
        5: [26, 28, 32],
76
        6: [25, 27, 31],
77
        7: [25, 28, 31],
78
        8: [24, 26, 29],
79
        9: [24, 25, 27],
80
        10: [25, 26, 28],
81
        11: [24, 25, 26],
82
        12: [22, 29, 30],
83
        13: [21, 27, 30],
84
        14: [23, 28, 32],
85
        15: [23, 28, 31],
86
        16: [22, 29, 32],
87
        17: [21, 27, 31],
88
        18: [21, 22, 30],
89
        19: [22, 23, 32],
90
        20: [21, 23, 31],
91
        21: [1, 13, 17, 18, 20],
92
        22: [1, 12, 16, 18, 19],
93
        23: [1, 14, 15, 19, 20],
94
        24: [2, 3, 8, 9, 11],
95
        25: [6, 7, 9, 10, 11],
96
        26: [4, 5, 8, 10, 11],
97
        27: [2, 6, 9, 13, 17],
98
        28: [5, 7, 10, 14, 15],
99
        29: [3, 4, 8, 12, 16],
100
        30: [2, 3, 12, 13, 18],
101
        31: [6, 7, 15, 17, 20],
102
        32: [4, 5, 14, 16, 19]
103
    },
104
    'Small Rhombicosidodecahedral Graph': {
105
        1: [2, 3, 4, 5],
106
        2: [1, 54, 55, 59],
107
        3: [1, 53, 56, 60],
108
        4: [1, 5, 58, 60],
109
        5: [1, 4, 57, 59],
110
        6: [24, 25, 57, 58],
111
        7: [12, 13, 16, 17],
112
        8: [9, 11, 19, 25],
113
        9: [8, 10, 18, 24],
114
        10: [9, 11, 12, 18],
115
        11: [8, 10, 13, 19],
116
        12: [7, 10, 14, 20],
117
        13: [7, 11, 15, 21],
118
        14: [12, 18, 20, 37],
119
        15: [13, 19, 21, 38],
120
        16: [7, 17, 21, 23],
121
        17: [7, 16, 20, 22],
122
        18: [9, 10, 14, 28],
123
        19: [8, 11, 15, 29],
124
        20: [12, 14, 17, 33],
125
        21: [13, 15, 16, 32],
126
        22: [17, 23, 31, 34],
127
        23: [16, 22, 30, 34],
128
        24: [6, 9, 27, 28],
129
        25: [6, 8, 26, 29],
130
        26: [25, 29, 46, 58],
131
        27: [24, 28, 45, 57],
132
        28: [18, 24, 27, 44],
133
        29: [19, 25, 26, 43],
134
        30: [23, 32, 36, 42],
135
        31: [22, 33, 35, 41],
136
        32: [21, 30, 38, 39],
137
        33: [20, 31, 37, 40],
138
        34: [22, 23, 41, 42],
139
        35: [31, 40, 41, 51],
140
        36: [30, 39, 42, 52],
141
        37: [14, 33, 40, 44],
142
        38: [15, 32, 39, 43],
143
        39: [32, 36, 38, 48],
144
        40: [33, 35, 37, 47],
145
        41: [31, 34, 35, 50],
146
        42: [30, 34, 36, 49],
147
        43: [29, 38, 46, 48],
148
        44: [28, 37, 45, 47],
149
        45: [27, 44, 47, 59],
150
        46: [26, 43, 48, 60],
151
        47: [40, 44, 45, 54],
152
        48: [39, 43, 46, 53],
153
        49: [42, 50, 52, 56],
154
        50: [41, 49, 51, 55],
155
        51: [35, 50, 54, 55],
156
        52: [36, 49, 53, 56],
157
        53: [3, 48, 52, 60],
158
        54: [2, 47, 51, 59],
159
        55: [2, 50, 51, 56],
160
        56: [3, 49, 52, 55],
161
        57: [5, 6, 27, 58],
162
        58: [4, 6, 26, 57],
163
        59: [2, 5, 45, 54],
164
        60: [3, 4, 46, 53]
165
    },
166
    'Small Rhombicuboctahedral Graph': {
167
        1: [2, 3, 4, 5],
168
        2: [1, 18, 22, 24],
169
        3: [1, 19, 22, 23],
170
        4: [1, 5, 21, 24],
171
        5: [1, 4, 20, 23],
172
        6: [10, 11, 20, 21],
173
        7: [10, 11, 12, 13],
174
        8: [10, 14, 20, 23],
175
        9: [11, 15, 21, 24],
176
        10: [6, 7, 8, 14],
177
        11: [6, 7, 9, 15],
178
        12: [7, 13, 15, 17],
179
        13: [7, 12, 14, 16],
180
        14: [8, 10, 13, 19],
181
        15: [9, 11, 12, 18],
182
        16: [13, 17, 19, 22],
183
        17: [12, 16, 18, 22],
184
        18: [2, 15, 17, 24],
185
        19: [3, 14, 16, 23],
186
        20: [5, 6, 8, 21],
187
        21: [4, 6, 9, 20],
188
        22: [2, 3, 16, 17],
189
        23: [3, 5, 8, 19],
190
        24: [2, 4, 9, 18]
191
    },
192
    'Great Rhombicosidodecahedral Graph': {
193
        1: [2, 3, 4],
194
        2: [1, 119, 120],
195
        3: [1, 118, 120],
196
        4: [1, 116, 117],
197
        5: [6, 7, 120],
198
        6: [5, 114, 115],
199
        7: [5, 113, 115],
200
        8: [9, 10, 115],
201
        9: [8, 111, 112],
202
        10: [8, 110, 112],
203
        11: [12, 13, 112],
204
        12: [11, 108, 109],
205
        13: [11, 107, 109],
206
        14: [15, 16, 109],
207
        15: [14, 105, 106],
208
        16: [14, 104, 106],
209
        17: [18, 19, 106],
210
        18: [17, 102, 103],
211
        19: [17, 101, 103],
212
        20: [21, 22, 103],
213
        21: [20, 99, 100],
214
        22: [20, 98, 100],
215
        23: [24, 25, 100],
216
        24: [23, 96, 97],
217
        25: [23, 95, 97],
218
        26: [27, 28, 97],
219
        27: [26, 93, 94],
220
        28: [26, 92, 94],
221
        29: [94, 116, 117],
222
        30: [63, 91, 96],
223
        31: [32, 33, 91],
224
        32: [31, 87, 88],
225
        33: [31, 86, 88],
226
        34: [35, 36, 88],
227
        35: [34, 84, 85],
228
        36: [34, 83, 85],
229
        37: [38, 85, 113],
230
        38: [37, 41, 110],
231
        39: [58, 73, 114],
232
        40: [86, 117, 119],
233
        41: [38, 64, 84],
234
        42: [64, 69, 84],
235
        43: [53, 55, 111],
236
        44: [64, 67, 108],
237
        45: [52, 77, 105],
238
        46: [65, 70, 102],
239
        47: [48, 49, 99],
240
        48: [47, 82, 95],
241
        49: [47, 80, 81],
242
        50: [51, 52, 79],
243
        51: [50, 74, 75],
244
        52: [45, 50, 75],
245
        53: [43, 75, 107],
246
        54: [72, 73, 74],
247
        55: [43, 73, 74],
248
        56: [61, 76, 78],
249
        57: [60, 89, 90],
250
        58: [39, 59, 118],
251
        59: [58, 60, 72],
252
        60: [57, 59, 61],
253
        61: [56, 60, 72],
254
        62: [66, 71, 87],
255
        63: [30, 66, 87],
256
        64: [41, 42, 44],
257
        65: [46, 66, 98],
258
        66: [62, 63, 65],
259
        67: [44, 68, 104],
260
        68: [67, 69, 70],
261
        69: [42, 68, 71],
262
        70: [46, 68, 71],
263
        71: [62, 69, 70],
264
        72: [54, 59, 61],
265
        73: [39, 54, 55],
266
        74: [51, 54, 55],
267
        75: [51, 52, 53],
268
        76: [56, 82, 89],
269
        77: [45, 80, 101],
270
        78: [56, 81, 82],
271
        79: [50, 80, 81],
272
        80: [49, 77, 79],
273
        81: [49, 78, 79],
274
        82: [48, 76, 78],
275
        83: [36, 86, 119],
276
        84: [35, 41, 42],
277
        85: [35, 36, 37],
278
        86: [33, 40, 83],
279
        87: [32, 62, 63],
280
        88: [32, 33, 34],
281
        89: [57, 76, 93],
282
        90: [57, 93, 116],
283
        91: [30, 31, 92],
284
        92: [28, 91, 96],
285
        93: [27, 89, 90],
286
        94: [27, 28, 29],
287
        95: [25, 48, 99],
288
        96: [24, 30, 92],
289
        97: [24, 25, 26],
290
        98: [22, 65, 102],
291
        99: [21, 47, 95],
292
        100: [21, 22, 23],
293
        101: [19, 77, 105],
294
        102: [18, 46, 98],
295
        103: [18, 19, 20],
296
        104: [16, 67, 108],
297
        105: [15, 45, 101],
298
        106: [15, 16, 17],
299
        107: [13, 53, 111],
300
        108: [12, 44, 104],
301
        109: [12, 13, 14],
302
        110: [10, 38, 113],
303
        111: [9, 43, 107],
304
        112: [9, 10, 11],
305
        113: [7, 37, 110],
306
        114: [6, 39, 118],
307
        115: [6, 7, 8],
308
        116: [4, 29, 90],
309
        117: [4, 29, 40],
310
        118: [3, 58, 114],
311
        119: [2, 40, 83],
312
        120: [2, 3, 5]
313
    },
314
    'Disdyakis Dodecahedral Graph': {
315
        1: [13, 14, 21, 22],
316
        2: [17, 19, 21, 23],
317
        3: [18, 20, 22, 24],
318
        4: [16, 17, 23, 25],
319
        5: [15, 19, 23, 26],
320
        6: [15, 18, 24, 26],
321
        7: [16, 20, 24, 25],
322
        8: [15, 16, 23, 24],
323
        9: [14, 17, 21, 25],
324
        10: [13, 18, 22, 26],
325
        11: [13, 19, 21, 26],
326
        12: [14, 20, 22, 25],
327
        13: [1, 10, 11, 21, 22, 26],
328
        14: [1, 9, 12, 21, 22, 25],
329
        15: [5, 6, 8, 23, 24, 26],
330
        16: [4, 7, 8, 23, 24, 25],
331
        17: [2, 4, 9, 21, 23, 25],
332
        18: [3, 6, 10, 22, 24, 26],
333
        19: [2, 5, 11, 21, 23, 26],
334
        20: [3, 7, 12, 22, 24, 25],
335
        21: [1, 2, 9, 11, 13, 14, 17, 19],
336
        22: [1, 3, 10, 12, 13, 14, 18, 20],
337
        23: [2, 4, 5, 8, 15, 16, 17, 19],
338
        24: [3, 6, 7, 8, 15, 16, 18, 20],
339
        25: [4, 7, 9, 12, 14, 16, 17, 20],
340
        26: [5, 6, 10, 11, 13, 15, 18, 19]
341
    },
342
    'Deltoidal Icositetrahedral Graph': {
343
        1: [15, 24, 26],
344
        2: [15, 23, 25],
345
        3: [16, 18, 20],
346
        4: [17, 19, 20],
347
        5: [16, 22, 26],
348
        6: [19, 22, 25],
349
        7: [18, 21, 24],
350
        8: [17, 21, 23],
351
        9: [15, 22, 25, 26],
352
        10: [15, 21, 23, 24],
353
        11: [16, 18, 24, 26],
354
        12: [17, 19, 23, 25],
355
        13: [16, 19, 20, 22],
356
        14: [17, 18, 20, 21],
357
        15: [1, 2, 9, 10],
358
        16: [3, 5, 11, 13],
359
        17: [4, 8, 12, 14],
360
        18: [3, 7, 11, 14],
361
        19: [4, 6, 12, 13],
362
        20: [3, 4, 13, 14],
363
        21: [7, 8, 10, 14],
364
        22: [5, 6, 9, 13],
365
        23: [2, 8, 10, 12],
366
        24: [1, 7, 10, 11],
367
        25: [2, 6, 9, 12],
368
        26: [1, 5, 9, 11]
369
    },
370
    'Icosidodecahedral Graph': {
371
        1: [2, 3, 4, 5],
372
        2: [1, 4, 23, 27],
373
        3: [1, 5, 24, 28],
374
        4: [1, 2, 26, 29],
375
        5: [1, 3, 25, 30],
376
        6: [7, 8, 9, 10],
377
        7: [6, 9, 11, 15],
378
        8: [6, 10, 12, 16],
379
        9: [6, 7, 14, 18],
380
        10: [6, 8, 13, 17],
381
        11: [7, 12, 15, 19],
382
        12: [8, 11, 16, 19],
383
        13: [10, 14, 17, 20],
384
        14: [9, 13, 18, 20],
385
        15: [7, 11, 21, 23],
386
        16: [8, 12, 22, 24],
387
        17: [10, 13, 22, 25],
388
        18: [9, 14, 21, 26],
389
        19: [11, 12, 27, 28],
390
        20: [13, 14, 29, 30],
391
        21: [15, 18, 23, 26],
392
        22: [16, 17, 24, 25],
393
        23: [2, 15, 21, 27],
394
        24: [3, 16, 22, 28],
395
        25: [5, 17, 22, 30],
396
        26: [4, 18, 21, 29],
397
        27: [2, 19, 23, 28],
398
        28: [3, 19, 24, 27],
399
        29: [4, 20, 26, 30],
400
        30: [5, 20, 25, 29]
401
    },
402
    'Deltoidal Hexecontahedral Graph': {
403
        1: [21, 49, 50],
404
        2: [21, 47, 48],
405
        3: [23, 25, 26],
406
        4: [22, 24, 26],
407
        5: [25, 27, 33],
408
        6: [24, 30, 36],
409
        7: [23, 28, 34],
410
        8: [22, 29, 35],
411
        9: [27, 30, 31],
412
        10: [28, 29, 32],
413
        11: [33, 38, 43],
414
        12: [34, 38, 46],
415
        13: [36, 37, 45],
416
        14: [35, 37, 44],
417
        15: [32, 40, 42],
418
        16: [31, 39, 41],
419
        17: [39, 43, 49],
420
        18: [40, 46, 50],
421
        19: [41, 45, 47],
422
        20: [42, 44, 48],
423
        21: [1, 2, 51, 52],
424
        22: [4, 8, 54, 56],
425
        23: [3, 7, 53, 56],
426
        24: [4, 6, 54, 55],
427
        25: [3, 5, 53, 55],
428
        26: [3, 4, 55, 56],
429
        27: [5, 9, 55, 57],
430
        28: [7, 10, 56, 58],
431
        29: [8, 10, 56, 60],
432
        30: [6, 9, 55, 59],
433
        31: [9, 16, 57, 59],
434
        32: [10, 15, 58, 60],
435
        33: [5, 11, 53, 57],
436
        34: [7, 12, 53, 58],
437
        35: [8, 14, 54, 60],
438
        36: [6, 13, 54, 59],
439
        37: [13, 14, 54, 62],
440
        38: [11, 12, 53, 61],
441
        39: [16, 17, 52, 57],
442
        40: [15, 18, 51, 58],
443
        41: [16, 19, 52, 59],
444
        42: [15, 20, 51, 60],
445
        43: [11, 17, 57, 61],
446
        44: [14, 20, 60, 62],
447
        45: [13, 19, 59, 62],
448
        46: [12, 18, 58, 61],
449
        47: [2, 19, 52, 62],
450
        48: [2, 20, 51, 62],
451
        49: [1, 17, 52, 61],
452
        50: [1, 18, 51, 61],
453
        51: [21, 40, 42, 48, 50],
454
        52: [21, 39, 41, 47, 49],
455
        53: [23, 25, 33, 34, 38],
456
        54: [22, 24, 35, 36, 37],
457
        55: [24, 25, 26, 27, 30],
458
        56: [22, 23, 26, 28, 29],
459
        57: [27, 31, 33, 39, 43],
460
        58: [28, 32, 34, 40, 46],
461
        59: [30, 31, 36, 41, 45],
462
        60: [29, 32, 35, 42, 44],
463
        61: [38, 43, 46, 49, 50],
464
        62: [37, 44, 45, 47, 48]
465
    },
466
    'Kocohl74': {
467
        1: [2, 3, 4],
468
        2: [1, 71, 74],
469
        3: [1, 72, 73],
470
        4: [1, 69, 70],
471
        5: [6, 43, 60],
472
        6: [5, 7, 50],
473
        7: [6, 8, 9],
474
        8: [7, 39, 40],
475
        9: [7, 41, 42],
476
        10: [11, 12, 31],
477
        11: [10, 21, 25],
478
        12: [10, 20, 22],
479
        13: [15, 18, 24],
480
        14: [15, 44, 47],
481
        15: [13, 14, 45],
482
        16: [17, 46, 47],
483
        17: [16, 18, 21],
484
        18: [13, 17, 22],
485
        19: [20, 21, 23],
486
        20: [12, 19, 24],
487
        21: [11, 17, 19],
488
        22: [12, 18, 23],
489
        23: [19, 22, 28],
490
        24: [13, 20, 26],
491
        25: [11, 26, 27],
492
        26: [24, 25, 35],
493
        27: [25, 30, 37],
494
        28: [23, 29, 35],
495
        29: [28, 30, 34],
496
        30: [27, 29, 33],
497
        31: [10, 33, 34],
498
        32: [40, 46, 48],
499
        33: [30, 31, 42],
500
        34: [29, 31, 41],
501
        35: [26, 28, 42],
502
        36: [38, 39, 43],
503
        37: [27, 38, 41],
504
        38: [36, 37, 40],
505
        39: [8, 36, 49],
506
        40: [8, 32, 38],
507
        41: [9, 34, 37],
508
        42: [9, 33, 35],
509
        43: [5, 36, 54],
510
        44: [14, 49, 52],
511
        45: [15, 48, 52],
512
        46: [16, 32, 56],
513
        47: [14, 16, 51],
514
        48: [32, 45, 57],
515
        49: [39, 44, 51],
516
        50: [6, 55, 58],
517
        51: [47, 49, 66],
518
        52: [44, 45, 65],
519
        53: [58, 63, 67],
520
        54: [43, 59, 63],
521
        55: [50, 59, 62],
522
        56: [46, 57, 66],
523
        57: [48, 56, 65],
524
        58: [50, 53, 61],
525
        59: [54, 55, 64],
526
        60: [5, 62, 64],
527
        61: [58, 68, 71],
528
        62: [55, 60, 72],
529
        63: [53, 54, 72],
530
        64: [59, 60, 71],
531
        65: [52, 57, 70],
532
        66: [51, 56, 69],
533
        67: [53, 70, 74],
534
        68: [61, 69, 73],
535
        69: [4, 66, 68],
536
        70: [4, 65, 67],
537
        71: [2, 61, 64],
538
        72: [3, 62, 63],
539
        73: [3, 68, 74],
540
        74: [2, 67, 73]
541
    },
542
    'https://houseofgraphs.org/graphs/3312': {
543
        1: [2, 3, 4],
544
        2: [1, 87, 88],
545
        3: [1, 85, 88],
546
        4: [1, 84, 86],
547
        5: [6, 7, 88],
548
        6: [5, 83, 87],
549
        7: [5, 81, 82],
550
        8: [83, 84, 86],
551
        9: [10, 11, 83],
552
        10: [9, 80, 86],
553
        11: [9, 79, 82],
554
        12: [28, 29, 80],
555
        13: [28, 45, 80],
556
        14: [16, 19, 81],
557
        15: [19, 78, 81],
558
        16: [14, 17, 82],
559
        17: [16, 18, 79],
560
        18: [17, 19, 20],
561
        19: [14, 15, 18],
562
        20: [18, 77, 78],
563
        21: [22, 23, 76],
564
        22: [21, 72, 75],
565
        23: [21, 73, 74],
566
        24: [25, 34, 85],
567
        25: [24, 26, 27],
568
        26: [25, 33, 38],
569
        27: [25, 32, 34],
570
        28: [12, 13, 31],
571
        29: [12, 30, 37],
572
        30: [29, 31, 36],
573
        31: [28, 30, 39],
574
        32: [27, 33, 40],
575
        33: [26, 32, 35],
576
        34: [24, 27, 43],
577
        35: [33, 38, 44],
578
        36: [30, 37, 42],
579
        37: [29, 36, 41],
580
        38: [26, 35, 41],
581
        39: [31, 42, 45],
582
        40: [32, 43, 44],
583
        41: [37, 38, 47],
584
        42: [36, 39, 47],
585
        43: [34, 40, 46],
586
        44: [35, 40, 50],
587
        45: [13, 39, 51],
588
        46: [43, 65, 85],
589
        47: [41, 42, 64],
590
        48: [53, 57, 63],
591
        49: [52, 56, 60],
592
        50: [44, 52, 61],
593
        51: [45, 53, 62],
594
        52: [49, 50, 65],
595
        53: [48, 51, 64],
596
        54: [59, 63, 71],
597
        55: [58, 60, 70],
598
        56: [49, 58, 61],
599
        57: [48, 59, 62],
600
        58: [55, 56, 67],
601
        59: [54, 57, 69],
602
        60: [49, 55, 66],
603
        61: [50, 56, 67],
604
        62: [51, 57, 69],
605
        63: [48, 54, 68],
606
        64: [47, 53, 68],
607
        65: [46, 52, 66],
608
        66: [60, 65, 72],
609
        67: [58, 61, 75],
610
        68: [63, 64, 74],
611
        69: [59, 62, 73],
612
        70: [55, 72, 75],
613
        71: [54, 73, 74],
614
        72: [22, 66, 70],
615
        73: [23, 69, 71],
616
        74: [23, 68, 71],
617
        75: [22, 67, 70],
618
        76: [21, 77, 78],
619
        77: [20, 76, 79],
620
        78: [15, 20, 76],
621
        79: [11, 17, 77],
622
        80: [10, 12, 13],
623
        81: [7, 14, 15],
624
        82: [7, 11, 16],
625
        83: [6, 8, 9],
626
        84: [4, 8, 87],
627
        85: [3, 24, 46],
628
        86: [4, 8, 10],
629
        87: [2, 6, 84],
630
        88: [2, 3, 5]
631
    },
632
    'https://houseofgraphs.org/graphs/31104': {
633
        1: [2, 3, 4, 5],
634
        2: [1, 4, 9, 10],
635
        3: [1, 5, 8, 10],
636
        4: [1, 2, 6, 8],
637
        5: [1, 3, 7, 9],
638
        6: [4, 7, 8, 10],
639
        7: [5, 6, 9, 10],
640
        8: [3, 4, 6, 9],
641
        9: [2, 5, 7, 8],
642
        10: [2, 3, 6, 7]
643
    },
644
    'Utility Graph': {
645
        1: [2, 3, 4],
646
        2: [1, 5, 6],
647
        3: [1, 5, 6],
648
        4: [1, 5, 6],
649
        5: [2, 3, 4],
650
        6: [2, 3, 4]
651
    },
652
    'Errara Graph': {
653
        1: [3, 4, 5, 11, 12],
654
        2: [6, 7, 8, 9, 10],
655
        3: [1, 4, 5, 13, 14],
656
        4: [1, 3, 11, 13, 16],
657
        5: [1, 3, 12, 14, 17],
658
        6: [2, 7, 8, 15, 16],
659
        7: [2, 6, 9, 15, 17],
660
        8: [2, 6, 10, 13, 16],
661
        9: [2, 7, 10, 14, 17],
662
        10: [2, 8, 9, 13, 14],
663
        11: [1, 4, 12, 15, 16],
664
        12: [1, 5, 11, 15, 17],
665
        13: [3, 4, 8, 10, 14, 16],
666
        14: [3, 5, 9, 10, 13, 17],
667
        15: [6, 7, 11, 12, 16, 17],
668
        16: [4, 6, 8, 11, 13, 15],
669
        17: [5, 7, 9, 12, 14, 15]
670
    },
671
    'Dragon Curve Blob 6': {
672
        1: [4, 15],
673
        2: [8, 17],
674
        3: [8, 17],
675
        4: [1, 14],
676
        5: [7, 14],
677
        6: [7, 14],
678
        7: [5, 6],
679
        8: [2, 3],
680
        9: [11, 16],
681
        10: [13, 15],
682
        11: [9, 12],
683
        12: [11, 16, 17],
684
        13: [10, 16, 17],
685
        14: [4, 5, 6, 15],
686
        15: [1, 10, 14, 16],
687
        16: [9, 12, 13, 15],
688
        17: [2, 3, 12, 13]
689
    }
690
}
691
692
AdjacencyList = NewType('AdjacencyList', dict[int, list[int]])
693
694
695
def ladder_ring_graph(size: int):
696
    ring = nx.ladder_graph(size)
697
    ring.add_edge(size, size * 2 - 1)
698
    ring.add_edge(0, size - 1)
699
    return ladder_ring_graph
700
701
702
def ladder_mobius_graph(size: int):
703
    mobius = nx.ladder_graph(size)
704
    mobius.add_edge(size, size - 1)
705
    mobius.add_edge(0, size * 2 - 1)
706
    return mobius
707
708
709
def _cylinder_edges(circumference: int, length: int) -> Iterable[tuple[int, int]]:
710
    for k in range(length):
711
        start = k * circumference
712
        stop = (k + 1) * circumference - 1
713
        if k > 0:
714
            yield start, start - circumference
715
            yield stop, stop - circumference
716
        for i in range(start, stop):
717
            yield i, i + 1
718
            if k > 0:
719
                yield i, i - circumference
720
        yield stop, start
721
722
723
def cylinder_graph(circumference: int, length: int) -> nx.Graph:
724
    return nx.Graph(_cylinder_edges(circumference, length))
725
726
727
def _spiral_edges(n, k) -> Iterable[tuple[int, int]]:
728
    for i in range(n):
729
        yield i, i + 1
730
        if i - k >= 0:
731
            yield i, i - k
732
    yield n, n - k
733
734
735
def spiral_graph(n, k) -> nx.Graph:
736
    return nx.Graph(_spiral_edges(n, k))
737
738
739
def _spiral_torus_edges(n, k) -> Iterable[tuple[int, int]]:
740
    yield from _spiral_edges(n - 1, k)
741
    yield n - 1, 0
742
    for i in range(k):
743
        yield i, n - k + i
744
745
746
def spiral_torus_graph(n, k) -> nx.Graph:
747
    return nx.Graph(_spiral_torus_edges(n, k))
748
749
750
def adjacency_edges(adjacency_list: AdjacencyList) -> Iterable[tuple[int, int]]:
751
    yield from itertools.chain.from_iterable(
752
        ((k, t) for t in v)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable t does not seem to be defined.
Loading history...
753
        for k, v
754
        in adjacency_list.items()
755
    )
756
757
758
def from_adjacency_lists(adjacency_lists: dict[str, AdjacencyList]) -> dict[str, nx.Graph]:
759
    items = (
760
        (name, adjacency_edges(adjacency_list))
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable name does not seem to be defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable adjacency_list does not seem to be defined.
Loading history...
761
        for name, adjacency_list
762
        in adjacency_lists.items()
763
    )
764
765
    return {n: nx.Graph(list(e)) for n, e in items}
766
767
768
def special_graphs():
769
    return from_adjacency_lists(SPECIAL_GRAPHS_ADJACENCY_LISTS)
770
771
772
def atlas():
773
    """
774
    Generate a dictionary of various graph structures and models based on the provided atlas.
775
    The function creates different types of graphs and models using NetworkX library.
776
    The generated graphs include Tetrahedron, Cube, Octahedron, Dodecahedron, Icosahedron, Tesseract, Truncated Cube,
777
    Truncated Tetrahedron, Ladder, Ring, Möbius, Cylinder, Spiral, Spiral Torus, and Circulant[10,[2]].
778
    Additionally, the function includes adjacency mappings for specific named graphs like
779
    Buckyball - Truncated Icosahedral Graph, D30 - Rhombic Triacontahedral Graph, Small Rhombicosidodecahedral Graph,
780
    Small Rhombicuboctahedral Graph, Great Rhombicosidodecahedral Graph, Disdyakis Dodecahedral Graph,
781
    Deltoidal Icositetrahedral Graph, Icosidodecahedral Graph, Deltoidal Hexecontahedral Graph, Kocohl74,
782
    Utility Graph, Errara Graph, and Dragon Curve Blob 6.
783
    The adjacency mappings define the connections between nodes in each named graph.
784
    The function returns a dictionary
785
    containing the named graphs as keys and their corresponding NetworkX graph objects as values.
786
    """
787
788
    graph_atlas = {
789
        'Tetrahedron': nx.tetrahedral_graph(),
790
        'Cube': nx.hypercube_graph(3),
791
        'Octahedron': nx.octahedral_graph(),
792
        'Dodecahedron': nx.dodecahedral_graph(),
793
        'Icosahedron': nx.icosahedral_graph(),
794
        'Tesseract': nx.hypercube_graph(4),
795
        'Truncated Cube': nx.truncated_cube_graph(),
796
        'Truncated Tetrahedron': nx.truncated_tetrahedron_graph(),
797
        'Ladder': nx.ladder_graph(16),
798
        'Ring': ladder_ring_graph(16),
799
        'Möbius': ladder_mobius_graph(16),
800
        'Cylinder': cylinder_graph(6, 8),
801
        'Spiral': spiral_graph(18, 8),
802
        'Spiral Torus': spiral_torus_graph(128, 8),
803
        'Circulant[10,[2]]': nx.circulant_graph(10, [2])
804
    }
805
806
    graph_atlas.update(special_graphs())
807
808
    return graph_atlas
809