兮尘 commited on
Commit
18768dd
·
1 Parent(s): cf7c393

🎉 [add index.html] Initial commit with Ramsey Graph Visualizer structure

Browse files
Files changed (1) hide show
  1. index.html +1905 -0
index.html ADDED
@@ -0,0 +1,1905 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Ramsey Graph Visualizer</title>
7
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.8.5/d3.min.js"></script>
8
+ <link rel="preconnect" href="https://fonts.googleapis.com">
9
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
+ <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Fraunces:opsz,wght@9..144,300;9..144,600&display=swap" rel="stylesheet">
11
+ <style>
12
+ :root {
13
+ --bg-primary: #0a0a0a;
14
+ --bg-secondary: #1a1a1a;
15
+ --border-color: #2a2a2a;
16
+ --text-primary: #e8e8e8;
17
+ --text-secondary: #888888;
18
+ --accent-red: #ff3366;
19
+ --accent-blue: #00d4ff;
20
+ --accent-green: #00ff88;
21
+ --mono: 'JetBrains Mono', monospace;
22
+ --serif: 'Fraunces', serif;
23
+ }
24
+
25
+ * { margin: 0; padding: 0; box-sizing: border-box; }
26
+
27
+ html, body {
28
+ height: 100%;
29
+ overflow: hidden;
30
+ }
31
+
32
+ body {
33
+ background: var(--bg-primary);
34
+ color: var(--text-primary);
35
+ font-family: var(--mono);
36
+ font-size: 13px;
37
+ display: flex;
38
+ flex-direction: column;
39
+ }
40
+
41
+ body::before {
42
+ content: '';
43
+ position: fixed;
44
+ top: 0; left: 0;
45
+ width: 100%; height: 100%;
46
+ background-image:
47
+ linear-gradient(rgba(255, 51, 102, 0.03) 1px, transparent 1px),
48
+ linear-gradient(90deg, rgba(255, 51, 102, 0.03) 1px, transparent 1px);
49
+ background-size: 40px 40px;
50
+ pointer-events: none;
51
+ z-index: 0;
52
+ animation: gridPulse 8s ease-in-out infinite;
53
+ }
54
+
55
+ @keyframes gridPulse {
56
+ 0%, 100% { opacity: 0.3; }
57
+ 50% { opacity: 0.6; }
58
+ }
59
+
60
+ .app {
61
+ position: relative;
62
+ z-index: 1;
63
+ display: flex;
64
+ flex-direction: column;
65
+ height: 100vh;
66
+ padding: 16px 24px;
67
+ gap: 12px;
68
+ }
69
+
70
+ header {
71
+ display: flex;
72
+ justify-content: space-between;
73
+ align-items: center;
74
+ padding-bottom: 12px;
75
+ border-bottom: 1px solid var(--border-color);
76
+ flex-shrink: 0;
77
+ }
78
+
79
+ .title-area {
80
+ display: flex;
81
+ align-items: baseline;
82
+ gap: 16px;
83
+ }
84
+
85
+ h1 {
86
+ font-family: var(--serif);
87
+ font-size: 28px;
88
+ font-weight: 600;
89
+ background: linear-gradient(135deg, var(--text-primary), var(--accent-red));
90
+ -webkit-background-clip: text;
91
+ -webkit-text-fill-color: transparent;
92
+ background-clip: text;
93
+ }
94
+
95
+ .subtitle {
96
+ font-size: 11px;
97
+ color: var(--text-secondary);
98
+ text-transform: uppercase;
99
+ letter-spacing: 0.1em;
100
+ }
101
+
102
+ .header-actions {
103
+ display: flex;
104
+ align-items: center;
105
+ gap: 12px;
106
+ }
107
+
108
+ .action-btn {
109
+ display: flex;
110
+ align-items: center;
111
+ gap: 6px;
112
+ padding: 8px 14px;
113
+ font-size: 12px;
114
+ border: 1px solid var(--border-color);
115
+ background: transparent;
116
+ color: var(--text-secondary);
117
+ cursor: pointer;
118
+ font-family: var(--mono);
119
+ transition: all 0.2s ease;
120
+ }
121
+
122
+ .action-btn:hover {
123
+ border-color: var(--accent-green);
124
+ color: var(--accent-green);
125
+ }
126
+
127
+ .btn-icon {
128
+ width: 16px;
129
+ height: 16px;
130
+ flex-shrink: 0;
131
+ }
132
+
133
+ .lang-toggle {
134
+ display: flex;
135
+ gap: 4px;
136
+ }
137
+
138
+ .lang-btn {
139
+ display: flex;
140
+ align-items: center;
141
+ gap: 6px;
142
+ padding: 6px 12px;
143
+ font-size: 12px;
144
+ border: 1px solid var(--border-color);
145
+ background: transparent;
146
+ color: var(--text-secondary);
147
+ cursor: pointer;
148
+ font-family: var(--mono);
149
+ transition: all 0.2s ease;
150
+ }
151
+
152
+ .lang-icon {
153
+ width: 14px;
154
+ height: 14px;
155
+ flex-shrink: 0;
156
+ }
157
+
158
+ .lang-btn.active {
159
+ border-color: var(--accent-blue);
160
+ background: var(--accent-blue);
161
+ color: var(--bg-primary);
162
+ }
163
+
164
+ .lang-btn:hover:not(.active) {
165
+ border-color: var(--accent-blue);
166
+ color: var(--accent-blue);
167
+ }
168
+
169
+ .main-content {
170
+ display: flex;
171
+ gap: 16px;
172
+ flex: 1;
173
+ min-height: 0;
174
+ }
175
+
176
+ .sidebar {
177
+ width: 280px;
178
+ flex-shrink: 0;
179
+ display: flex;
180
+ flex-direction: column;
181
+ gap: 12px;
182
+ }
183
+
184
+ .panel {
185
+ background: var(--bg-secondary);
186
+ border: 1px solid var(--border-color);
187
+ padding: 16px;
188
+ }
189
+
190
+ .panel-title {
191
+ font-size: 10px;
192
+ text-transform: uppercase;
193
+ letter-spacing: 0.15em;
194
+ color: var(--text-secondary);
195
+ margin-bottom: 12px;
196
+ display: flex;
197
+ align-items: center;
198
+ gap: 8px;
199
+ }
200
+
201
+ .panel-title::before {
202
+ content: '';
203
+ width: 8px;
204
+ height: 8px;
205
+ background: var(--accent-red);
206
+ }
207
+
208
+ .selector-grid {
209
+ display: grid;
210
+ grid-template-columns: 1fr 1fr 1fr;
211
+ gap: 8px;
212
+ margin-bottom: 12px;
213
+ }
214
+
215
+ .selector-item label {
216
+ display: block;
217
+ font-size: 10px;
218
+ color: var(--text-secondary);
219
+ margin-bottom: 4px;
220
+ text-transform: uppercase;
221
+ letter-spacing: 0.1em;
222
+ }
223
+
224
+ select {
225
+ width: 100%;
226
+ background: var(--bg-primary);
227
+ border: 1px solid var(--border-color);
228
+ color: var(--text-primary);
229
+ padding: 8px;
230
+ font-family: var(--mono);
231
+ font-size: 13px;
232
+ cursor: pointer;
233
+ }
234
+
235
+ select:focus {
236
+ outline: none;
237
+ border-color: var(--accent-red);
238
+ }
239
+
240
+ select:disabled {
241
+ opacity: 0.5;
242
+ cursor: not-allowed;
243
+ }
244
+
245
+ .btn {
246
+ width: 100%;
247
+ padding: 10px;
248
+ font-family: var(--mono);
249
+ font-size: 11px;
250
+ text-transform: uppercase;
251
+ letter-spacing: 0.1em;
252
+ border: 1px solid var(--border-color);
253
+ background: var(--bg-primary);
254
+ color: var(--text-primary);
255
+ cursor: pointer;
256
+ transition: all 0.2s ease;
257
+ }
258
+
259
+ .btn:hover:not(:disabled) {
260
+ border-color: var(--accent-red);
261
+ background: var(--accent-red);
262
+ color: var(--bg-primary);
263
+ }
264
+
265
+ .btn:disabled {
266
+ opacity: 0.4;
267
+ cursor: not-allowed;
268
+ }
269
+
270
+ .btn-primary {
271
+ border-color: var(--accent-red);
272
+ background: rgba(255, 51, 102, 0.1);
273
+ }
274
+
275
+ .input-row {
276
+ display: flex;
277
+ gap: 8px;
278
+ margin-bottom: 8px;
279
+ }
280
+
281
+ input[type="text"] {
282
+ flex: 1;
283
+ background: var(--bg-primary);
284
+ border: 1px solid var(--border-color);
285
+ color: var(--text-primary);
286
+ padding: 8px 10px;
287
+ font-family: var(--mono);
288
+ font-size: 12px;
289
+ }
290
+
291
+ input[type="text"]:focus {
292
+ outline: none;
293
+ border-color: var(--accent-red);
294
+ }
295
+
296
+ input[type="file"] {
297
+ display: none;
298
+ }
299
+
300
+ .file-label {
301
+ display: block;
302
+ padding: 10px;
303
+ text-align: center;
304
+ border: 1px dashed var(--border-color);
305
+ color: var(--text-secondary);
306
+ cursor: pointer;
307
+ font-size: 11px;
308
+ transition: all 0.2s ease;
309
+ }
310
+
311
+ .file-label:hover {
312
+ border-color: var(--accent-red);
313
+ color: var(--accent-red);
314
+ }
315
+
316
+ .file-label.has-file {
317
+ border-style: solid;
318
+ border-color: var(--accent-green);
319
+ color: var(--accent-green);
320
+ }
321
+
322
+ .divider {
323
+ text-align: center;
324
+ color: var(--text-secondary);
325
+ font-size: 10px;
326
+ margin: 8px 0;
327
+ position: relative;
328
+ }
329
+
330
+ .divider::before, .divider::after {
331
+ content: '';
332
+ position: absolute;
333
+ top: 50%;
334
+ width: 40%;
335
+ height: 1px;
336
+ background: var(--border-color);
337
+ }
338
+
339
+ .divider::before { left: 0; }
340
+ .divider::after { right: 0; }
341
+
342
+ .status {
343
+ padding: 8px 10px;
344
+ font-size: 11px;
345
+ border-left: 3px solid var(--accent-blue);
346
+ background: rgba(0, 212, 255, 0.05);
347
+ display: none;
348
+ }
349
+
350
+ .status.show { display: block; }
351
+ .status.error {
352
+ border-color: var(--accent-red);
353
+ background: rgba(255, 51, 102, 0.05);
354
+ color: var(--accent-red);
355
+ }
356
+ .status.success {
357
+ border-color: var(--accent-green);
358
+ background: rgba(0, 255, 136, 0.05);
359
+ color: var(--accent-green);
360
+ }
361
+
362
+ .canvas-area {
363
+ flex: 1;
364
+ display: flex;
365
+ flex-direction: column;
366
+ background: var(--bg-secondary);
367
+ border: 1px solid var(--border-color);
368
+ min-width: 0;
369
+ }
370
+
371
+ .canvas-header {
372
+ display: flex;
373
+ justify-content: space-between;
374
+ align-items: center;
375
+ padding: 12px 16px;
376
+ border-bottom: 1px solid var(--border-color);
377
+ flex-shrink: 0;
378
+ flex-wrap: wrap;
379
+ gap: 12px;
380
+ }
381
+
382
+ .header-left {
383
+ display: flex;
384
+ align-items: center;
385
+ gap: 20px;
386
+ }
387
+
388
+ .header-right {
389
+ display: flex;
390
+ align-items: center;
391
+ gap: 16px;
392
+ }
393
+
394
+ .graph-info {
395
+ display: flex;
396
+ gap: 20px;
397
+ }
398
+
399
+ .info-item {
400
+ text-align: center;
401
+ }
402
+
403
+ .info-value {
404
+ font-size: 18px;
405
+ font-weight: 700;
406
+ color: var(--accent-red);
407
+ }
408
+
409
+ .info-label {
410
+ font-size: 9px;
411
+ text-transform: uppercase;
412
+ letter-spacing: 0.1em;
413
+ color: var(--text-secondary);
414
+ }
415
+
416
+ .toggle-group {
417
+ display: flex;
418
+ gap: 4px;
419
+ }
420
+
421
+ .toggle-btn {
422
+ padding: 6px 12px;
423
+ font-size: 10px;
424
+ text-transform: uppercase;
425
+ border: 1px solid var(--border-color);
426
+ background: transparent;
427
+ color: var(--text-secondary);
428
+ cursor: pointer;
429
+ font-family: var(--mono);
430
+ }
431
+
432
+ .toggle-btn.active {
433
+ border-color: var(--accent-red);
434
+ background: var(--accent-red);
435
+ color: var(--bg-primary);
436
+ }
437
+
438
+ .toggle-btn:hover:not(.active) {
439
+ border-color: var(--accent-red);
440
+ color: var(--accent-red);
441
+ }
442
+
443
+ #canvas {
444
+ flex: 1;
445
+ position: relative;
446
+ overflow: hidden;
447
+ }
448
+
449
+ #canvas svg {
450
+ width: 100%;
451
+ height: 100%;
452
+ }
453
+
454
+ .empty-state {
455
+ position: absolute;
456
+ top: 50%;
457
+ left: 50%;
458
+ transform: translate(-50%, -50%);
459
+ text-align: center;
460
+ color: var(--text-secondary);
461
+ }
462
+
463
+ .empty-icon {
464
+ font-size: 48px;
465
+ opacity: 0.3;
466
+ margin-bottom: 8px;
467
+ font-family: var(--serif);
468
+ }
469
+
470
+ .pagination {
471
+ display: flex;
472
+ align-items: center;
473
+ justify-content: center;
474
+ gap: 8px;
475
+ padding: 10px;
476
+ border-top: 1px solid var(--border-color);
477
+ flex-shrink: 0;
478
+ }
479
+
480
+ .pagination button {
481
+ padding: 6px 12px;
482
+ font-family: var(--mono);
483
+ font-size: 11px;
484
+ border: 1px solid var(--border-color);
485
+ background: transparent;
486
+ color: var(--text-secondary);
487
+ cursor: pointer;
488
+ }
489
+
490
+ .pagination button:hover:not(:disabled) {
491
+ border-color: var(--accent-red);
492
+ color: var(--accent-red);
493
+ }
494
+
495
+ .pagination button:disabled {
496
+ opacity: 0.3;
497
+ cursor: not-allowed;
498
+ }
499
+
500
+ .page-info {
501
+ min-width: 100px;
502
+ text-align: center;
503
+ color: var(--text-secondary);
504
+ font-size: 12px;
505
+ }
506
+
507
+ .page-info span {
508
+ color: var(--accent-red);
509
+ font-weight: 700;
510
+ }
511
+
512
+ .node { cursor: pointer; }
513
+ .node:hover { filter: brightness(1.3); }
514
+ .link { stroke-opacity: 0.6; }
515
+ .node-label {
516
+ font-family: var(--mono);
517
+ font-size: 10px;
518
+ fill: var(--text-primary);
519
+ text-anchor: middle;
520
+ pointer-events: none;
521
+ }
522
+
523
+ .legend {
524
+ display: flex;
525
+ gap: 16px;
526
+ font-size: 10px;
527
+ color: var(--text-secondary);
528
+ }
529
+
530
+ .legend-item {
531
+ display: flex;
532
+ align-items: center;
533
+ gap: 6px;
534
+ }
535
+
536
+ .legend-dot {
537
+ width: 10px;
538
+ height: 10px;
539
+ border-radius: 50%;
540
+ }
541
+
542
+ .legend-dot.red { background: var(--accent-red); }
543
+ .legend-dot.blue { background: var(--accent-blue); }
544
+
545
+ .loading {
546
+ position: absolute;
547
+ top: 50%;
548
+ left: 50%;
549
+ transform: translate(-50%, -50%);
550
+ color: var(--text-secondary);
551
+ }
552
+
553
+ .loading::after {
554
+ content: '';
555
+ display: inline-block;
556
+ width: 16px;
557
+ height: 16px;
558
+ border: 2px solid var(--border-color);
559
+ border-top-color: var(--accent-red);
560
+ border-radius: 50%;
561
+ animation: spin 0.8s linear infinite;
562
+ margin-left: 8px;
563
+ vertical-align: middle;
564
+ }
565
+
566
+ @keyframes spin {
567
+ to { transform: rotate(360deg); }
568
+ }
569
+
570
+ /* Matrix styles */
571
+ .matrix-container {
572
+ position: absolute;
573
+ top: 0;
574
+ left: 0;
575
+ right: 0;
576
+ bottom: 0;
577
+ display: flex;
578
+ align-items: center;
579
+ justify-content: center;
580
+ overflow: auto;
581
+ padding: 20px;
582
+ }
583
+
584
+ .matrix-wrapper {
585
+ display: flex;
586
+ flex-direction: column;
587
+ align-items: center;
588
+ }
589
+
590
+ .matrix-labels-top {
591
+ display: flex;
592
+ margin-left: 30px;
593
+ }
594
+
595
+ .matrix-label {
596
+ width: var(--cell-size, 24px);
597
+ height: 20px;
598
+ display: flex;
599
+ align-items: center;
600
+ justify-content: center;
601
+ font-size: 10px;
602
+ color: var(--text-secondary);
603
+ }
604
+
605
+ .matrix-row {
606
+ display: flex;
607
+ align-items: center;
608
+ }
609
+
610
+ .matrix-row-label {
611
+ width: 30px;
612
+ height: var(--cell-size, 24px);
613
+ display: flex;
614
+ align-items: center;
615
+ justify-content: center;
616
+ font-size: 10px;
617
+ color: var(--text-secondary);
618
+ }
619
+
620
+ .matrix-cell {
621
+ width: var(--cell-size, 24px);
622
+ height: var(--cell-size, 24px);
623
+ border: 1px solid var(--border-color);
624
+ display: flex;
625
+ align-items: center;
626
+ justify-content: center;
627
+ font-size: 10px;
628
+ transition: all 0.15s ease;
629
+ }
630
+
631
+ .matrix-cell.edge {
632
+ background: var(--accent-red);
633
+ color: var(--bg-primary);
634
+ font-weight: 700;
635
+ }
636
+
637
+ .matrix-cell.complement {
638
+ background: var(--accent-blue);
639
+ color: var(--bg-primary);
640
+ font-weight: 700;
641
+ }
642
+
643
+ .matrix-cell.diagonal {
644
+ background: var(--bg-primary);
645
+ color: var(--text-secondary);
646
+ }
647
+
648
+ .matrix-cell.empty {
649
+ background: transparent;
650
+ color: var(--text-secondary);
651
+ }
652
+
653
+ .matrix-cell:hover:not(.diagonal) {
654
+ transform: scale(1.1);
655
+ z-index: 10;
656
+ box-shadow: 0 0 10px rgba(255, 51, 102, 0.5);
657
+ }
658
+
659
+ /* Modal styles */
660
+ .modal {
661
+ display: none;
662
+ position: fixed;
663
+ top: 0;
664
+ left: 0;
665
+ right: 0;
666
+ bottom: 0;
667
+ z-index: 1000;
668
+ align-items: center;
669
+ justify-content: center;
670
+ }
671
+
672
+ .modal.show {
673
+ display: flex;
674
+ }
675
+
676
+ .modal-overlay {
677
+ position: absolute;
678
+ top: 0;
679
+ left: 0;
680
+ right: 0;
681
+ bottom: 0;
682
+ background: rgba(0, 0, 0, 0.8);
683
+ }
684
+
685
+ .modal-content {
686
+ position: relative;
687
+ background: var(--bg-secondary);
688
+ border: 1px solid var(--border-color);
689
+ max-width: 600px;
690
+ max-height: 80vh;
691
+ width: 90%;
692
+ display: flex;
693
+ flex-direction: column;
694
+ }
695
+
696
+ .modal-content.modal-large {
697
+ max-width: 900px;
698
+ }
699
+
700
+ .modal-header {
701
+ display: flex;
702
+ justify-content: space-between;
703
+ align-items: center;
704
+ padding: 16px 20px;
705
+ border-bottom: 1px solid var(--border-color);
706
+ }
707
+
708
+ .modal-header h2 {
709
+ font-family: var(--serif);
710
+ font-size: 20px;
711
+ font-weight: 600;
712
+ color: var(--text-primary);
713
+ }
714
+
715
+ .modal-close {
716
+ width: 32px;
717
+ height: 32px;
718
+ display: flex;
719
+ align-items: center;
720
+ justify-content: center;
721
+ border: 1px solid var(--border-color);
722
+ background: transparent;
723
+ color: var(--text-secondary);
724
+ font-size: 20px;
725
+ cursor: pointer;
726
+ transition: all 0.2s ease;
727
+ }
728
+
729
+ .modal-close:hover {
730
+ border-color: var(--accent-red);
731
+ color: var(--accent-red);
732
+ }
733
+
734
+ .modal-body {
735
+ padding: 20px;
736
+ overflow-y: auto;
737
+ font-size: 13px;
738
+ line-height: 1.7;
739
+ color: var(--text-secondary);
740
+ }
741
+
742
+ .modal-body p {
743
+ margin-bottom: 12px;
744
+ }
745
+
746
+ .modal-body strong {
747
+ color: var(--text-primary);
748
+ }
749
+
750
+ .modal-body .highlight {
751
+ color: var(--accent-red);
752
+ font-weight: 700;
753
+ }
754
+
755
+ .modal-body .challenge {
756
+ padding: 16px;
757
+ margin: 16px 0;
758
+ background: rgba(255, 51, 102, 0.1);
759
+ border-left: 3px solid var(--accent-red);
760
+ }
761
+
762
+ .modal-body .significance {
763
+ padding: 16px;
764
+ margin: 16px 0;
765
+ background: rgba(0, 212, 255, 0.1);
766
+ border-left: 3px solid var(--accent-blue);
767
+ }
768
+
769
+ /* Progress table */
770
+ .ramsey-table {
771
+ width: 100%;
772
+ border-collapse: collapse;
773
+ font-size: 11px;
774
+ margin-top: 12px;
775
+ }
776
+
777
+ .ramsey-table th,
778
+ .ramsey-table td {
779
+ padding: 8px 6px;
780
+ border: 1px solid var(--border-color);
781
+ text-align: center;
782
+ }
783
+
784
+ .ramsey-table th {
785
+ background: var(--bg-primary);
786
+ color: var(--accent-red);
787
+ font-weight: 700;
788
+ }
789
+
790
+ .ramsey-table td.exact {
791
+ background: rgba(0, 255, 136, 0.1);
792
+ color: var(--accent-green);
793
+ }
794
+
795
+ .ramsey-table td.range {
796
+ background: rgba(0, 212, 255, 0.1);
797
+ color: var(--accent-blue);
798
+ }
799
+
800
+ .ramsey-table td.trivial {
801
+ color: var(--text-secondary);
802
+ }
803
+
804
+ .table-legend {
805
+ display: flex;
806
+ gap: 20px;
807
+ margin-top: 16px;
808
+ font-size: 11px;
809
+ }
810
+
811
+ .table-legend-item {
812
+ display: flex;
813
+ align-items: center;
814
+ gap: 8px;
815
+ }
816
+
817
+ .legend-box {
818
+ width: 16px;
819
+ height: 16px;
820
+ }
821
+
822
+ .legend-box.exact {
823
+ background: rgba(0, 255, 136, 0.1);
824
+ border: 1px solid var(--accent-green);
825
+ }
826
+
827
+ .legend-box.range {
828
+ background: rgba(0, 212, 255, 0.1);
829
+ border: 1px solid var(--accent-blue);
830
+ }
831
+
832
+ /* Wiki link bottom right */
833
+ .wiki-link {
834
+ position: fixed;
835
+ bottom: 20px;
836
+ right: 20px;
837
+ display: flex;
838
+ align-items: center;
839
+ gap: 8px;
840
+ padding: 10px 14px;
841
+ background: var(--bg-secondary);
842
+ border: 1px solid var(--border-color);
843
+ color: var(--text-secondary);
844
+ text-decoration: none;
845
+ font-size: 12px;
846
+ transition: all 0.2s ease;
847
+ z-index: 100;
848
+ }
849
+
850
+ .wiki-link:hover {
851
+ border-color: var(--accent-blue);
852
+ color: var(--accent-blue);
853
+ }
854
+
855
+ .wiki-icon-svg {
856
+ width: 20px;
857
+ height: 20px;
858
+ flex-shrink: 0;
859
+ }
860
+
861
+ /* Links panel */
862
+ .panel-links {
863
+ margin-top: auto;
864
+ }
865
+
866
+ .link-list {
867
+ display: flex;
868
+ flex-direction: column;
869
+ gap: 6px;
870
+ }
871
+
872
+ .link-list a {
873
+ display: flex;
874
+ align-items: center;
875
+ gap: 10px;
876
+ padding: 8px 10px;
877
+ background: var(--bg-primary);
878
+ border: 1px solid var(--border-color);
879
+ color: var(--text-secondary);
880
+ text-decoration: none;
881
+ font-size: 11px;
882
+ transition: all 0.2s ease;
883
+ }
884
+
885
+ .link-list a:hover {
886
+ border-color: var(--accent-red);
887
+ color: var(--text-primary);
888
+ }
889
+
890
+ .link-icon {
891
+ width: 28px;
892
+ height: 28px;
893
+ display: flex;
894
+ align-items: center;
895
+ justify-content: center;
896
+ background: var(--border-color);
897
+ color: var(--text-primary);
898
+ flex-shrink: 0;
899
+ padding: 5px;
900
+ }
901
+
902
+ .link-icon svg {
903
+ width: 100%;
904
+ height: 100%;
905
+ }
906
+
907
+ .link-list a:hover .link-icon {
908
+ background: var(--accent-red);
909
+ color: var(--bg-primary);
910
+ }
911
+
912
+ .link-text {
913
+ overflow: hidden;
914
+ text-overflow: ellipsis;
915
+ white-space: nowrap;
916
+ }
917
+
918
+ @media (max-width: 900px) {
919
+ .main-content {
920
+ flex-direction: column;
921
+ }
922
+ .sidebar {
923
+ width: 100%;
924
+ flex-direction: row;
925
+ flex-wrap: wrap;
926
+ }
927
+ .sidebar .panel {
928
+ flex: 1;
929
+ min-width: 200px;
930
+ }
931
+ .panel-links {
932
+ margin-top: 0;
933
+ }
934
+ .canvas-header {
935
+ flex-direction: column;
936
+ align-items: flex-start;
937
+ }
938
+ }
939
+ </style>
940
+ </head>
941
+ <body>
942
+ <div class="app">
943
+ <header>
944
+ <div class="title-area">
945
+ <h1>Ramsey Graph</h1>
946
+ <span class="subtitle" data-i18n="subtitle">Interactive Visualizer</span>
947
+ </div>
948
+ <div class="header-actions">
949
+ <button class="action-btn" id="introBtn">
950
+ <svg class="btn-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
951
+ <path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"></path>
952
+ <path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"></path>
953
+ </svg>
954
+ <span data-i18n="introduction">Introduction</span>
955
+ </button>
956
+ <button class="action-btn" id="progressBtn">
957
+ <svg class="btn-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
958
+ <path d="M18 20V10"></path>
959
+ <path d="M12 20V4"></path>
960
+ <path d="M6 20v-6"></path>
961
+ </svg>
962
+ <span data-i18n="progress">Progress</span>
963
+ </button>
964
+ <div class="lang-toggle">
965
+ <button class="lang-btn active" data-lang="en">
966
+ <svg class="lang-icon" viewBox="0 0 24 24" fill="currentColor">
967
+ <circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="1.5"/>
968
+ <path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" fill="none" stroke="currentColor" stroke-width="1.5"/>
969
+ </svg>
970
+ EN
971
+ </button>
972
+ <button class="lang-btn" data-lang="zh">
973
+ <svg class="lang-icon" viewBox="0 0 24 24" fill="currentColor">
974
+ <circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="1.5"/>
975
+ <path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" fill="none" stroke="currentColor" stroke-width="1.5"/>
976
+ </svg>
977
+ 中文
978
+ </button>
979
+ </div>
980
+ </div>
981
+ </header>
982
+
983
+ <div class="main-content">
984
+ <div class="sidebar">
985
+ <div class="panel">
986
+ <div class="panel-title" data-i18n="selectDataset">Select Dataset</div>
987
+ <div class="selector-grid">
988
+ <div class="selector-item">
989
+ <label>s</label>
990
+ <select id="selectS"></select>
991
+ </div>
992
+ <div class="selector-item">
993
+ <label>t</label>
994
+ <select id="selectT"></select>
995
+ </div>
996
+ <div class="selector-item">
997
+ <label>n</label>
998
+ <select id="selectN"></select>
999
+ </div>
1000
+ </div>
1001
+ <button class="btn btn-primary" id="loadDatasetBtn" data-i18n="loadDataset">Load Ramsey(s,t,n)</button>
1002
+ <div id="datasetInfo" style="margin-top: 8px; font-size: 10px; color: var(--text-secondary);"></div>
1003
+ </div>
1004
+
1005
+ <div class="panel">
1006
+ <div class="panel-title" data-i18n="customSource">Custom Source</div>
1007
+ <div class="input-row">
1008
+ <input type="text" id="urlInput" data-i18n-placeholder="urlPlaceholder" placeholder="Enter .g6 file URL...">
1009
+ </div>
1010
+ <button class="btn" id="loadUrlBtn" data-i18n="loadUrl">Load URL</button>
1011
+ <div class="divider" data-i18n="or">or</div>
1012
+ <input type="file" id="fileInput" accept=".g6">
1013
+ <label class="file-label" id="fileLabel" for="fileInput" data-i18n="uploadFile">
1014
+ Drop or click to upload .g6 file
1015
+ </label>
1016
+ </div>
1017
+
1018
+ <div id="status" class="status"></div>
1019
+
1020
+ <div class="panel panel-links">
1021
+ <div class="panel-title" data-i18n="links">Links</div>
1022
+ <div class="link-list">
1023
+ <a href="https://huggingface.co/datasets/linxy/RamseyGraph" target="_blank">
1024
+ <span class="link-icon">
1025
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1026
+ <path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path>
1027
+ <polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline>
1028
+ <line x1="12" y1="22.08" x2="12" y2="12"></line>
1029
+ </svg>
1030
+ </span>
1031
+ <span class="link-text" data-i18n="hfDataset">HuggingFace Dataset</span>
1032
+ </a>
1033
+ <a href="https://github.com/LinXueyuanStdio/RamseyGraph" target="_blank">
1034
+ <span class="link-icon">
1035
+ <svg viewBox="0 0 24 24" fill="currentColor">
1036
+ <path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/>
1037
+ </svg>
1038
+ </span>
1039
+ <span class="link-text" data-i18n="ghRepo">GitHub Repository</span>
1040
+ </a>
1041
+ <a href="https://users.cecs.anu.edu.au/~bdm/data/ramsey.html" target="_blank">
1042
+ <span class="link-icon">
1043
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1044
+ <ellipse cx="12" cy="5" rx="9" ry="3"></ellipse>
1045
+ <path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"></path>
1046
+ <path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"></path>
1047
+ </svg>
1048
+ </span>
1049
+ <span class="link-text" data-i18n="originDb">Origin Database</span>
1050
+ </a>
1051
+ <a href="mailto:linxy59@mail2.sysu.edu.cn">
1052
+ <span class="link-icon">
1053
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1054
+ <path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path>
1055
+ <polyline points="22,6 12,13 2,6"></polyline>
1056
+ </svg>
1057
+ </span>
1058
+ <span class="link-text" data-i18n="contact">Contact</span>
1059
+ </a>
1060
+ <a href="https://www.combinatorics.org" target="_blank">
1061
+ <span class="link-icon">
1062
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1063
+ <path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"></path>
1064
+ <path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"></path>
1065
+ </svg>
1066
+ </span>
1067
+ <span class="link-text" data-i18n="wiki">E-JC Survey</span>
1068
+ </a>
1069
+ </div>
1070
+ </div>
1071
+ </div>
1072
+
1073
+ <div class="canvas-area">
1074
+ <div class="canvas-header">
1075
+ <div class="header-left">
1076
+ <div class="graph-info">
1077
+ <div class="info-item">
1078
+ <div class="info-value" id="nodeCount">-</div>
1079
+ <div class="info-label" data-i18n="nodes">Nodes</div>
1080
+ </div>
1081
+ <div class="info-item">
1082
+ <div class="info-value" id="edgeCount">-</div>
1083
+ <div class="info-label" data-i18n="edges">Edges</div>
1084
+ </div>
1085
+ </div>
1086
+ <div class="legend">
1087
+ <div class="legend-item"><div class="legend-dot red"></div><span data-i18n="graphG">Graph G</span></div>
1088
+ <div class="legend-item"><div class="legend-dot blue"></div><span data-i18n="complement">Complement</span></div>
1089
+ </div>
1090
+ </div>
1091
+ <div class="header-right">
1092
+ <div class="toggle-group" id="displayToggle">
1093
+ <button class="toggle-btn active" data-display="force" data-i18n="force">Force</button>
1094
+ <button class="toggle-btn" data-display="matrix" data-i18n="matrix">Matrix</button>
1095
+ </div>
1096
+ <div class="toggle-group" id="viewToggle">
1097
+ <button class="toggle-btn active" data-mode="graph">G</button>
1098
+ <button class="toggle-btn" data-mode="complement">G'</button>
1099
+ <button class="toggle-btn" data-mode="both" data-i18n="both">Both</button>
1100
+ </div>
1101
+ </div>
1102
+ </div>
1103
+ <div id="canvas">
1104
+ <div class="empty-state">
1105
+ <div class="empty-icon">R</div>
1106
+ <div data-i18n="emptyState">Select a dataset or upload a file</div>
1107
+ </div>
1108
+ </div>
1109
+ <div class="pagination" id="pagination" style="display: none;">
1110
+ <button id="prevBtn" data-i18n="prev">&lt; Prev</button>
1111
+ <div class="page-info">
1112
+ <span data-i18n="graph">Graph</span> <span id="currentPage">1</span> / <span id="totalPages">1</span>
1113
+ </div>
1114
+ <button id="nextBtn" data-i18n="next">Next &gt;</button>
1115
+ </div>
1116
+ </div>
1117
+ </div>
1118
+
1119
+ <!-- Introduction Modal -->
1120
+ <div class="modal" id="introModal">
1121
+ <div class="modal-overlay"></div>
1122
+ <div class="modal-content">
1123
+ <div class="modal-header">
1124
+ <h2 data-i18n="introTitle">What is a Ramsey Graph?</h2>
1125
+ <button class="modal-close">&times;</button>
1126
+ </div>
1127
+ <div class="modal-body" id="introBody">
1128
+ </div>
1129
+ </div>
1130
+ </div>
1131
+
1132
+ <!-- Progress Modal -->
1133
+ <div class="modal" id="progressModal">
1134
+ <div class="modal-overlay"></div>
1135
+ <div class="modal-content modal-large">
1136
+ <div class="modal-header">
1137
+ <h2 data-i18n="progressTitle">Known Ramsey Numbers</h2>
1138
+ <button class="modal-close">&times;</button>
1139
+ </div>
1140
+ <div class="modal-body" id="progressBody">
1141
+ </div>
1142
+ </div>
1143
+ </div>
1144
+
1145
+ <!-- Wiki link bottom right -->
1146
+ <a href="https://en.wikipedia.org/wiki/Ramsey%27s_theorem" target="_blank" class="wiki-link" title="Wikipedia: Ramsey's Theorem">
1147
+ <svg class="wiki-icon-svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
1148
+ <circle cx="12" cy="12" r="10"></circle>
1149
+ <path d="M12 16v-4"></path>
1150
+ <path d="M12 8h.01"></path>
1151
+ </svg>
1152
+ <span class="wiki-text" data-i18n="wikiLink">Wikipedia</span>
1153
+ </a>
1154
+ </div>
1155
+
1156
+ <script>
1157
+ // i18n translations
1158
+ const i18n = {
1159
+ en: {
1160
+ subtitle: 'Interactive Visualizer',
1161
+ selectDataset: 'Select Dataset',
1162
+ loadDataset: 'Load Ramsey(s,t,n)',
1163
+ customSource: 'Custom Source',
1164
+ urlPlaceholder: 'Enter .g6 file URL...',
1165
+ loadUrl: 'Load URL',
1166
+ or: 'or',
1167
+ uploadFile: 'Drop or click to upload .g6 file',
1168
+ links: 'Links',
1169
+ hfDataset: 'HuggingFace Dataset',
1170
+ ghRepo: 'GitHub Repository',
1171
+ originDb: 'Origin Database',
1172
+ contact: 'Contact',
1173
+ wiki: 'E-JC Survey',
1174
+ nodes: 'Nodes',
1175
+ edges: 'Edges',
1176
+ graphG: 'Graph G',
1177
+ complement: 'Complement',
1178
+ force: 'Force',
1179
+ matrix: 'Matrix',
1180
+ both: 'Both',
1181
+ emptyState: 'Select a dataset or upload a file',
1182
+ prev: '< Prev',
1183
+ next: 'Next >',
1184
+ graph: 'Graph',
1185
+ loading: 'Loading',
1186
+ loadedGraphs: 'Loaded {0} graph(s)',
1187
+ noValidGraphs: 'No valid graphs found',
1188
+ errorLoading: 'Error: {0}',
1189
+ failedToLoad: 'Failed to load',
1190
+ graphCount: '{0} graph(s)',
1191
+ compressed: '(compressed)',
1192
+ introduction: 'Introduction',
1193
+ progress: 'Progress',
1194
+ introTitle: 'What is a Ramsey Graph?',
1195
+ progressTitle: 'Known Ramsey Numbers',
1196
+ exactValue: 'Exact value known',
1197
+ rangeValue: 'Only bounds known',
1198
+ wikiLink: 'Wikipedia'
1199
+ },
1200
+ zh: {
1201
+ subtitle: '交互式可视化工具',
1202
+ selectDataset: '选择数据集',
1203
+ loadDataset: '加载 Ramsey(s,t,n)',
1204
+ customSource: '自定义来源',
1205
+ urlPlaceholder: '输入 .g6 文件 URL...',
1206
+ loadUrl: '加载 URL',
1207
+ or: '或',
1208
+ uploadFile: '拖放或点击上传 .g6 文件',
1209
+ links: '链接',
1210
+ hfDataset: 'HuggingFace 数据集',
1211
+ ghRepo: 'GitHub 仓库',
1212
+ originDb: '原始数据库',
1213
+ contact: '联系方式',
1214
+ wiki: '电子组合学期刊',
1215
+ nodes: '节点',
1216
+ edges: '边',
1217
+ graphG: '图 G',
1218
+ complement: '补图',
1219
+ force: '力导向',
1220
+ matrix: '矩阵',
1221
+ both: '两者',
1222
+ emptyState: '选择数据集或上传文件',
1223
+ prev: '< 上一个',
1224
+ next: '下一个 >',
1225
+ graph: '图',
1226
+ loading: '加载中',
1227
+ loadedGraphs: '已加载 {0} 个图',
1228
+ noValidGraphs: '未找到有效的图',
1229
+ errorLoading: '错误: {0}',
1230
+ failedToLoad: '加载失败',
1231
+ graphCount: '{0} 个图',
1232
+ compressed: '(压缩)',
1233
+ introduction: '介绍',
1234
+ progress: '进展',
1235
+ introTitle: '什么是拉姆齐图?',
1236
+ progressTitle: '已知拉姆齐数',
1237
+ exactValue: '精确值已知',
1238
+ rangeValue: '仅知道上下界',
1239
+ wikiLink: '维基百科'
1240
+ }
1241
+ };
1242
+
1243
+ const wikiUrls = {
1244
+ en: 'https://en.wikipedia.org/wiki/Ramsey%27s_theorem',
1245
+ zh: 'https://zh.wikipedia.org/wiki/%E6%8B%89%E5%A7%86%E9%BD%90%E5%AE%9A%E7%90%86'
1246
+ };
1247
+
1248
+ let currentLang = localStorage.getItem('lang') || 'en';
1249
+
1250
+ function t(key, ...args) {
1251
+ let text = i18n[currentLang][key] || i18n['en'][key] || key;
1252
+ args.forEach((arg, i) => {
1253
+ text = text.replace(`{${i}}`, arg);
1254
+ });
1255
+ return text;
1256
+ }
1257
+
1258
+ function applyLanguage() {
1259
+ document.querySelectorAll('[data-i18n]').forEach(el => {
1260
+ const key = el.getAttribute('data-i18n');
1261
+ el.textContent = t(key);
1262
+ });
1263
+ document.querySelectorAll('[data-i18n-placeholder]').forEach(el => {
1264
+ const key = el.getAttribute('data-i18n-placeholder');
1265
+ el.placeholder = t(key);
1266
+ });
1267
+ // Update wiki link URL based on language
1268
+ const wikiLink = document.querySelector('.wiki-link');
1269
+ if (wikiLink) {
1270
+ wikiLink.href = wikiUrls[currentLang] || wikiUrls.en;
1271
+ }
1272
+ // Update dataset info if loaded
1273
+ if (selectS.value) updateDatasetInfo();
1274
+ }
1275
+
1276
+ function setLanguage(lang) {
1277
+ currentLang = lang;
1278
+ localStorage.setItem('lang', lang);
1279
+ document.querySelectorAll('.lang-btn').forEach(btn => {
1280
+ btn.classList.toggle('active', btn.dataset.lang === lang);
1281
+ });
1282
+ applyLanguage();
1283
+ }
1284
+
1285
+ // Dataset configuration based on data/ folder
1286
+ const DATASETS = {
1287
+ '3,4': [1,2,3,4,5,6,7,8],
1288
+ '3,5': [1,2,3,4,5,6,7,8,9,10,11,12,13],
1289
+ '3,6': [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],
1290
+ '3,7': [21,22],
1291
+ '3,8': [27],
1292
+ '3,9': [35],
1293
+ '4,4': [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],
1294
+ '4,5': [24],
1295
+ '4,6': [35],
1296
+ '5,5': [42]
1297
+ };
1298
+
1299
+ // Files that are compressed (gzipped)
1300
+ const COMPRESSED = new Set([
1301
+ 'r36_11', 'r36_12', 'r36_13', 'r36_14', 'r36_15', 'r36_16',
1302
+ 'r37_21', 'r38_27',
1303
+ 'r44_10', 'r44_11', 'r44_12', 'r44_13', 'r44_14'
1304
+ ]);
1305
+
1306
+ // Approximate graph counts for info display
1307
+ const GRAPH_COUNTS = {
1308
+ 'r34_1':1,'r34_2':2,'r34_3':3,'r34_4':6,'r34_5':9,'r34_6':15,'r34_7':9,'r34_8':3,
1309
+ 'r35_1':1,'r35_2':2,'r35_3':3,'r35_4':7,'r35_5':13,'r35_6':32,'r35_7':71,'r35_8':179,'r35_9':290,'r35_10':313,'r35_11':105,'r35_12':12,'r35_13':1,
1310
+ 'r36_1':1,'r36_2':2,'r36_3':3,'r36_4':7,'r36_5':14,'r36_6':37,'r36_7':100,'r36_8':356,'r36_9':1407,'r36_10':6657,'r36_11':30395,'r36_12':116792,'r36_13':275086,'r36_14':263520,'r36_15':64732,'r36_16':2576,'r36_17':7,
1311
+ 'r37_21':1118436,'r37_22':191,
1312
+ 'r38_27':477142,
1313
+ 'r39_35':1,
1314
+ 'r44_1':1,'r44_2':2,'r44_3':4,'r44_4':9,'r44_5':24,'r44_6':84,'r44_7':362,'r44_8':2079,'r44_9':14701,'r44_10':103706,'r44_11':546356,'r44_12':1449166,'r44_13':1184231,'r44_14':130816,'r44_15':640,'r44_16':2,'r44_17':1,
1315
+ 'r45_24':352366,
1316
+ 'r46_35some':37,
1317
+ 'r55_42some':328
1318
+ };
1319
+
1320
+ // State
1321
+ let graphs = [];
1322
+ let currentIndex = 0;
1323
+ let viewMode = 'graph';
1324
+ let displayMode = 'force';
1325
+ let simulation = null;
1326
+
1327
+ // DOM
1328
+ const selectS = document.getElementById('selectS');
1329
+ const selectT = document.getElementById('selectT');
1330
+ const selectN = document.getElementById('selectN');
1331
+ const loadDatasetBtn = document.getElementById('loadDatasetBtn');
1332
+ const datasetInfo = document.getElementById('datasetInfo');
1333
+ const urlInput = document.getElementById('urlInput');
1334
+ const loadUrlBtn = document.getElementById('loadUrlBtn');
1335
+ const fileInput = document.getElementById('fileInput');
1336
+ const fileLabel = document.getElementById('fileLabel');
1337
+ const status = document.getElementById('status');
1338
+ const canvas = document.getElementById('canvas');
1339
+ const pagination = document.getElementById('pagination');
1340
+ const prevBtn = document.getElementById('prevBtn');
1341
+ const nextBtn = document.getElementById('nextBtn');
1342
+ const currentPage = document.getElementById('currentPage');
1343
+ const totalPages = document.getElementById('totalPages');
1344
+ const nodeCount = document.getElementById('nodeCount');
1345
+ const edgeCount = document.getElementById('edgeCount');
1346
+
1347
+ // Initialize selectors
1348
+ function initSelectors() {
1349
+ const sValues = [...new Set(Object.keys(DATASETS).map(k => k.split(',')[0]))].sort((a,b) => a-b);
1350
+ selectS.innerHTML = sValues.map(s => `<option value="${s}">${s}</option>`).join('');
1351
+ updateTOptions();
1352
+ }
1353
+
1354
+ function updateTOptions() {
1355
+ const s = selectS.value;
1356
+ const tValues = [...new Set(Object.keys(DATASETS).filter(k => k.startsWith(s+',')).map(k => k.split(',')[1]))].sort((a,b) => a-b);
1357
+ selectT.innerHTML = tValues.map(t => `<option value="${t}">${t}</option>`).join('');
1358
+ updateNOptions();
1359
+ }
1360
+
1361
+ function updateNOptions() {
1362
+ const key = `${selectS.value},${selectT.value}`;
1363
+ const nValues = DATASETS[key] || [];
1364
+ selectN.innerHTML = nValues.map(n => `<option value="${n}">${n}</option>`).join('');
1365
+ updateDatasetInfo();
1366
+ }
1367
+
1368
+ function updateDatasetInfo() {
1369
+ const s = selectS.value, tVal = selectT.value, n = selectN.value;
1370
+ const fileKey = `r${s}${tVal}_${n}`;
1371
+ const count = GRAPH_COUNTS[fileKey] || GRAPH_COUNTS[fileKey + 'some'] || '?';
1372
+ const isCompressed = COMPRESSED.has(fileKey);
1373
+ const countText = t('graphCount', count.toLocaleString());
1374
+ datasetInfo.innerHTML = `${countText}${isCompressed ? ` <span style="color:var(--accent-blue)">${t('compressed')}</span>` : ''}`;
1375
+ }
1376
+
1377
+ function getDatasetUrl() {
1378
+ const s = selectS.value, t = selectT.value, n = selectN.value;
1379
+ let fileKey = `r${s}${t}_${n}`;
1380
+ if (['4,6', '5,5'].includes(`${s},${t}`)) {
1381
+ fileKey += 'some';
1382
+ }
1383
+ const ext = COMPRESSED.has(fileKey.replace('some','')) ? '.g6.gz' : '.g6';
1384
+ return `https://huggingface.co/datasets/linxy/RamseyGraph/resolve/main/data/${fileKey}${ext}?download=true`;
1385
+ }
1386
+
1387
+ selectS.addEventListener('change', updateTOptions);
1388
+ selectT.addEventListener('change', updateNOptions);
1389
+ selectN.addEventListener('change', updateDatasetInfo);
1390
+
1391
+ // Status helper
1392
+ function showStatus(msg, type = 'info') {
1393
+ status.textContent = msg;
1394
+ status.className = `status show ${type}`;
1395
+ if (type !== 'error') {
1396
+ setTimeout(() => status.className = 'status', 3000);
1397
+ }
1398
+ }
1399
+
1400
+ // Parse graph6
1401
+ function parseGraph6(line) {
1402
+ line = line.trim();
1403
+ if (!line) return null;
1404
+
1405
+ let pos = 0;
1406
+ let n;
1407
+ const firstByte = line.charCodeAt(pos) - 63;
1408
+
1409
+ if (firstByte < 63) {
1410
+ n = firstByte;
1411
+ pos++;
1412
+ } else if (line.charCodeAt(pos + 1) - 63 < 63) {
1413
+ n = ((line.charCodeAt(pos + 1) - 63) << 12) |
1414
+ ((line.charCodeAt(pos + 2) - 63) << 6) |
1415
+ (line.charCodeAt(pos + 3) - 63);
1416
+ pos += 4;
1417
+ } else {
1418
+ n = ((line.charCodeAt(pos + 2) - 63) << 30) |
1419
+ ((line.charCodeAt(pos + 3) - 63) << 24) |
1420
+ ((line.charCodeAt(pos + 4) - 63) << 18) |
1421
+ ((line.charCodeAt(pos + 5) - 63) << 12) |
1422
+ ((line.charCodeAt(pos + 6) - 63) << 6) |
1423
+ (line.charCodeAt(pos + 7) - 63);
1424
+ pos += 8;
1425
+ }
1426
+
1427
+ const edges = [];
1428
+ let bitPos = 0;
1429
+ let currentByte = 0;
1430
+
1431
+ for (let j = 1; j < n; j++) {
1432
+ for (let i = 0; i < j; i++) {
1433
+ if (bitPos === 0) {
1434
+ if (pos >= line.length) break;
1435
+ currentByte = line.charCodeAt(pos) - 63;
1436
+ pos++;
1437
+ }
1438
+ const bit = (currentByte >> (5 - bitPos)) & 1;
1439
+ bitPos = (bitPos + 1) % 6;
1440
+ if (bit === 1) edges.push([i, j]);
1441
+ }
1442
+ }
1443
+
1444
+ return { nodes: n, edges };
1445
+ }
1446
+
1447
+ // Load functions
1448
+ async function loadFromUrl(url) {
1449
+ showStatus(t('loading') + '...', 'info');
1450
+ canvas.innerHTML = `<div class="loading">${t('loading')}</div>`;
1451
+
1452
+ try {
1453
+ const response = await fetch(url);
1454
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
1455
+
1456
+ let text;
1457
+ if (url.includes('.gz')) {
1458
+ const buffer = await response.arrayBuffer();
1459
+ const decompressed = await decompress(buffer);
1460
+ text = new TextDecoder().decode(decompressed);
1461
+ } else {
1462
+ text = await response.text();
1463
+ }
1464
+
1465
+ parseAndDisplay(text);
1466
+ showStatus(t('loadedGraphs', graphs.length), 'success');
1467
+ } catch (err) {
1468
+ showStatus(t('errorLoading', err.message), 'error');
1469
+ canvas.innerHTML = `<div class="empty-state"><div class="empty-icon">!</div><div>${t('failedToLoad')}</div></div>`;
1470
+ }
1471
+ }
1472
+
1473
+ async function decompress(buffer) {
1474
+ const ds = new DecompressionStream('gzip');
1475
+ const decompressedStream = new Response(new Blob([buffer]).stream().pipeThrough(ds)).arrayBuffer();
1476
+ return new Uint8Array(await decompressedStream);
1477
+ }
1478
+
1479
+ function loadFromFile(file) {
1480
+ showStatus(t('loading') + '...', 'info');
1481
+ const reader = new FileReader();
1482
+
1483
+ reader.onload = async (e) => {
1484
+ let text;
1485
+ if (file.name.endsWith('.gz')) {
1486
+ const decompressed = await decompress(e.target.result);
1487
+ text = new TextDecoder().decode(decompressed);
1488
+ } else {
1489
+ text = e.target.result;
1490
+ }
1491
+ parseAndDisplay(text);
1492
+ showStatus(t('loadedGraphs', graphs.length), 'success');
1493
+ };
1494
+
1495
+ reader.onerror = () => showStatus(t('errorLoading', 'File read error'), 'error');
1496
+
1497
+ if (file.name.endsWith('.gz')) {
1498
+ reader.readAsArrayBuffer(file);
1499
+ } else {
1500
+ reader.readAsText(file);
1501
+ }
1502
+ }
1503
+
1504
+ function parseAndDisplay(text) {
1505
+ graphs = [];
1506
+ const lines = text.split('\n');
1507
+ for (const line of lines) {
1508
+ const g = parseGraph6(line);
1509
+ if (g) graphs.push(g);
1510
+ }
1511
+
1512
+ if (graphs.length > 0) {
1513
+ currentIndex = 0;
1514
+ updatePagination();
1515
+ visualize(0);
1516
+ } else {
1517
+ showStatus(t('noValidGraphs'), 'error');
1518
+ }
1519
+ }
1520
+
1521
+ function updatePagination() {
1522
+ pagination.style.display = graphs.length > 1 ? 'flex' : 'none';
1523
+ currentPage.textContent = currentIndex + 1;
1524
+ totalPages.textContent = graphs.length;
1525
+ prevBtn.disabled = currentIndex === 0;
1526
+ nextBtn.disabled = currentIndex === graphs.length - 1;
1527
+ }
1528
+
1529
+ function getComplement(n, edges) {
1530
+ const set = new Set(edges.map(e => `${e[0]}-${e[1]}`));
1531
+ const comp = [];
1532
+ for (let i = 0; i < n; i++) {
1533
+ for (let j = i + 1; j < n; j++) {
1534
+ if (!set.has(`${i}-${j}`)) comp.push([i, j]);
1535
+ }
1536
+ }
1537
+ return comp;
1538
+ }
1539
+
1540
+ // Build adjacency matrix
1541
+ function buildAdjMatrix(n, edges) {
1542
+ const matrix = Array.from({ length: n }, () => Array(n).fill(0));
1543
+ for (const [i, j] of edges) {
1544
+ matrix[i][j] = 1;
1545
+ matrix[j][i] = 1;
1546
+ }
1547
+ return matrix;
1548
+ }
1549
+
1550
+ // Main visualization dispatcher
1551
+ function visualize(index) {
1552
+ if (index < 0 || index >= graphs.length) return;
1553
+ currentIndex = index;
1554
+ const g = graphs[index];
1555
+
1556
+ nodeCount.textContent = g.nodes;
1557
+ edgeCount.textContent = g.edges.length;
1558
+ updatePagination();
1559
+
1560
+ if (displayMode === 'force') {
1561
+ visualizeForce(g);
1562
+ } else {
1563
+ visualizeMatrix(g);
1564
+ }
1565
+ }
1566
+
1567
+ // Force-directed graph visualization
1568
+ function visualizeForce(g) {
1569
+ canvas.innerHTML = '';
1570
+
1571
+ const nodes = Array.from({ length: g.nodes }, (_, i) => ({ id: i }));
1572
+ let links = [];
1573
+
1574
+ if (viewMode === 'graph') {
1575
+ links = g.edges.map(e => ({ source: e[0], target: e[1], type: 'graph' }));
1576
+ } else if (viewMode === 'complement') {
1577
+ links = getComplement(g.nodes, g.edges).map(e => ({ source: e[0], target: e[1], type: 'complement' }));
1578
+ } else {
1579
+ links = g.edges.map(e => ({ source: e[0], target: e[1], type: 'graph' }));
1580
+ links = links.concat(getComplement(g.nodes, g.edges).map(e => ({ source: e[0], target: e[1], type: 'complement' })));
1581
+ }
1582
+
1583
+ const rect = canvas.getBoundingClientRect();
1584
+ const width = rect.width;
1585
+ const height = rect.height;
1586
+
1587
+ const svg = d3.select('#canvas').append('svg').attr('width', width).attr('height', height);
1588
+
1589
+ simulation = d3.forceSimulation(nodes)
1590
+ .force('link', d3.forceLink(links).id(d => d.id).distance(60))
1591
+ .force('charge', d3.forceManyBody().strength(-150))
1592
+ .force('center', d3.forceCenter(width / 2, height / 2))
1593
+ .force('collision', d3.forceCollide().radius(16));
1594
+
1595
+ const link = svg.append('g')
1596
+ .selectAll('line')
1597
+ .data(links)
1598
+ .join('line')
1599
+ .attr('class', 'link')
1600
+ .attr('stroke', d => d.type === 'graph' ? '#ff3366' : '#00d4ff')
1601
+ .attr('stroke-width', 2);
1602
+
1603
+ const node = svg.append('g')
1604
+ .selectAll('circle')
1605
+ .data(nodes)
1606
+ .join('circle')
1607
+ .attr('class', 'node')
1608
+ .attr('r', 8)
1609
+ .attr('fill', '#e8e8e8')
1610
+ .call(drag(simulation));
1611
+
1612
+ const label = svg.append('g')
1613
+ .selectAll('text')
1614
+ .data(nodes)
1615
+ .join('text')
1616
+ .attr('class', 'node-label')
1617
+ .text(d => d.id);
1618
+
1619
+ simulation.on('tick', () => {
1620
+ link.attr('x1', d => d.source.x).attr('y1', d => d.source.y)
1621
+ .attr('x2', d => d.target.x).attr('y2', d => d.target.y);
1622
+ node.attr('cx', d => d.x).attr('cy', d => d.y);
1623
+ label.attr('x', d => d.x).attr('y', d => d.y + 20);
1624
+ });
1625
+ }
1626
+
1627
+ // Matrix visualization
1628
+ function visualizeMatrix(g) {
1629
+ canvas.innerHTML = '';
1630
+
1631
+ const n = g.nodes;
1632
+ const edgeMatrix = buildAdjMatrix(n, g.edges);
1633
+ const compMatrix = buildAdjMatrix(n, getComplement(n, g.edges));
1634
+
1635
+ // Calculate cell size based on available space
1636
+ const rect = canvas.getBoundingClientRect();
1637
+ const availableSize = Math.min(rect.width - 80, rect.height - 60);
1638
+ const cellSize = Math.max(16, Math.min(32, Math.floor(availableSize / n)));
1639
+
1640
+ const container = document.createElement('div');
1641
+ container.className = 'matrix-container';
1642
+
1643
+ const wrapper = document.createElement('div');
1644
+ wrapper.className = 'matrix-wrapper';
1645
+ wrapper.style.setProperty('--cell-size', `${cellSize}px`);
1646
+
1647
+ // Top labels
1648
+ const topLabels = document.createElement('div');
1649
+ topLabels.className = 'matrix-labels-top';
1650
+ for (let j = 0; j < n; j++) {
1651
+ const label = document.createElement('div');
1652
+ label.className = 'matrix-label';
1653
+ label.textContent = j;
1654
+ topLabels.appendChild(label);
1655
+ }
1656
+ wrapper.appendChild(topLabels);
1657
+
1658
+ // Matrix rows
1659
+ for (let i = 0; i < n; i++) {
1660
+ const row = document.createElement('div');
1661
+ row.className = 'matrix-row';
1662
+
1663
+ // Row label
1664
+ const rowLabel = document.createElement('div');
1665
+ rowLabel.className = 'matrix-row-label';
1666
+ rowLabel.textContent = i;
1667
+ row.appendChild(rowLabel);
1668
+
1669
+ // Cells
1670
+ for (let j = 0; j < n; j++) {
1671
+ const cell = document.createElement('div');
1672
+ cell.className = 'matrix-cell';
1673
+
1674
+ if (i === j) {
1675
+ cell.classList.add('diagonal');
1676
+ cell.textContent = '-';
1677
+ } else {
1678
+ const isEdge = edgeMatrix[i][j] === 1;
1679
+ const isComp = compMatrix[i][j] === 1;
1680
+
1681
+ if (viewMode === 'graph') {
1682
+ if (isEdge) {
1683
+ cell.classList.add('edge');
1684
+ cell.textContent = '1';
1685
+ } else {
1686
+ cell.classList.add('empty');
1687
+ cell.textContent = '0';
1688
+ }
1689
+ } else if (viewMode === 'complement') {
1690
+ if (isComp) {
1691
+ cell.classList.add('complement');
1692
+ cell.textContent = '1';
1693
+ } else {
1694
+ cell.classList.add('empty');
1695
+ cell.textContent = '0';
1696
+ }
1697
+ } else { // both
1698
+ if (isEdge) {
1699
+ cell.classList.add('edge');
1700
+ cell.textContent = '1';
1701
+ } else if (isComp) {
1702
+ cell.classList.add('complement');
1703
+ cell.textContent = '1';
1704
+ } else {
1705
+ cell.classList.add('empty');
1706
+ cell.textContent = '0';
1707
+ }
1708
+ }
1709
+ }
1710
+
1711
+ cell.title = `(${i}, ${j})`;
1712
+ row.appendChild(cell);
1713
+ }
1714
+
1715
+ wrapper.appendChild(row);
1716
+ }
1717
+
1718
+ container.appendChild(wrapper);
1719
+ canvas.appendChild(container);
1720
+ }
1721
+
1722
+ function drag(sim) {
1723
+ return d3.drag()
1724
+ .on('start', e => { if (!e.active) sim.alphaTarget(0.3).restart(); e.subject.fx = e.subject.x; e.subject.fy = e.subject.y; })
1725
+ .on('drag', e => { e.subject.fx = e.x; e.subject.fy = e.y; })
1726
+ .on('end', e => { if (!e.active) sim.alphaTarget(0); e.subject.fx = null; e.subject.fy = null; });
1727
+ }
1728
+
1729
+ // Event listeners
1730
+ loadDatasetBtn.addEventListener('click', () => loadFromUrl(getDatasetUrl()));
1731
+
1732
+ loadUrlBtn.addEventListener('click', () => {
1733
+ const url = urlInput.value.trim();
1734
+ if (url) loadFromUrl(url);
1735
+ });
1736
+
1737
+ urlInput.addEventListener('keypress', e => {
1738
+ if (e.key === 'Enter') loadUrlBtn.click();
1739
+ });
1740
+
1741
+ fileInput.addEventListener('change', e => {
1742
+ if (e.target.files[0]) {
1743
+ fileLabel.textContent = e.target.files[0].name;
1744
+ fileLabel.classList.add('has-file');
1745
+ loadFromFile(e.target.files[0]);
1746
+ }
1747
+ });
1748
+
1749
+ prevBtn.addEventListener('click', () => { if (currentIndex > 0) visualize(currentIndex - 1); });
1750
+ nextBtn.addEventListener('click', () => { if (currentIndex < graphs.length - 1) visualize(currentIndex + 1); });
1751
+
1752
+ // Display mode toggle (Force / Matrix)
1753
+ document.querySelectorAll('#displayToggle .toggle-btn').forEach(btn => {
1754
+ btn.addEventListener('click', e => {
1755
+ document.querySelectorAll('#displayToggle .toggle-btn').forEach(b => b.classList.remove('active'));
1756
+ e.target.classList.add('active');
1757
+ displayMode = e.target.dataset.display;
1758
+ if (graphs.length > 0) visualize(currentIndex);
1759
+ });
1760
+ });
1761
+
1762
+ // View mode toggle (G / G' / Both)
1763
+ document.querySelectorAll('#viewToggle .toggle-btn').forEach(btn => {
1764
+ btn.addEventListener('click', e => {
1765
+ document.querySelectorAll('#viewToggle .toggle-btn').forEach(b => b.classList.remove('active'));
1766
+ e.target.classList.add('active');
1767
+ viewMode = e.target.dataset.mode;
1768
+ if (graphs.length > 0) visualize(currentIndex);
1769
+ });
1770
+ });
1771
+
1772
+ // Keyboard navigation
1773
+ document.addEventListener('keydown', e => {
1774
+ if (graphs.length === 0) return;
1775
+ if (e.key === 'ArrowLeft' || e.key === 'a') prevBtn.click();
1776
+ if (e.key === 'ArrowRight' || e.key === 'd') nextBtn.click();
1777
+ if (e.key === 'm') {
1778
+ displayMode = displayMode === 'force' ? 'matrix' : 'force';
1779
+ document.querySelectorAll('#displayToggle .toggle-btn').forEach(b => {
1780
+ b.classList.toggle('active', b.dataset.display === displayMode);
1781
+ });
1782
+ visualize(currentIndex);
1783
+ }
1784
+ });
1785
+
1786
+ // Language toggle
1787
+ document.querySelectorAll('.lang-btn').forEach(btn => {
1788
+ btn.addEventListener('click', () => setLanguage(btn.dataset.lang));
1789
+ });
1790
+
1791
+ // Modal content
1792
+ const trophyIcon = '<svg style="width:16px;height:16px;vertical-align:middle;margin-right:4px;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9H4.5a2.5 2.5 0 0 1 0-5H6"></path><path d="M18 9h1.5a2.5 2.5 0 0 0 0-5H18"></path><path d="M4 22h16"></path><path d="M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22"></path><path d="M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22"></path><path d="M18 2H6v7a6 6 0 0 0 12 0V2Z"></path></svg>';
1793
+ const lightbulbIcon = '<svg style="width:16px;height:16px;vertical-align:middle;margin-right:4px;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"></path><path d="M9 18h6"></path><path d="M10 22h4"></path></svg>';
1794
+ const introContent = {
1795
+ en: `
1796
+ <p><strong>A Ramsey(s,t,n) graph</strong> is a graph with <span class="highlight">n vertices</span> that contains no clique of size s and no independent set of size t.</p>
1797
+ <p>The <strong>Ramsey Theorem</strong> states that for given s and t, the number of Ramsey(s,t) graphs is finite. The minimum number of vertices for which no such graph exists is called the <strong>Ramsey Number R(s,t)</strong>.</p>
1798
+ <p>For given s and t, as the number of vertices n increases, there exists a <span class="highlight">critical threshold</span>—once n exceeds this threshold, a clique of size s or an independent set of size t <strong>must</strong> exist in any graph. Finding Ramsey graphs means finding this critical vertex count: the exact point where we can still find at least one special graph that contains neither a clique of size s nor an independent set of size t.</p>
1799
+ <div class="significance">
1800
+ <strong>${lightbulbIcon}Why It Matters:</strong> If we had an algorithm to determine the exact Ramsey number in advance, we would know precisely when certain substructures <strong>must</strong> appear in a system. This knowledge could help avoid maintaining excess nodes, potentially saving significant costs in network design, distributed systems, and other applications.
1801
+ </div>
1802
+ <p>Finding all such graphs, or even determining the maximum n for which they exist, is a famous problem in combinatorics. Most Ramsey numbers are still unknown—we only know upper and lower bounds.</p>
1803
+ <div class="challenge">
1804
+ <strong>${trophyIcon}Open Challenge:</strong> Find a <span class="highlight">Ramsey(5,5) graph with 43 vertices</span>!<br><br>
1805
+ All 42-vertex Ramsey(5,5) graphs have been found, but it's unknown if a 43-vertex one exists. The lower bound of R(5,5) hasn't been improved since <strong>1989</strong>. Finding just one such graph would be a major breakthrough—35 years in the making!
1806
+ </div>
1807
+ <p>For the latest research on Ramsey graphs, see <strong>Radziszowski's</strong> dynamic survey published in the <a href="https://www.combinatorics.org" target="_blank" style="color: var(--accent-blue);">Electronic Journal of Combinatorics</a>.</p>
1808
+ `,
1809
+ zh: `
1810
+ <p><strong>Ramsey(s,t,n) 图</strong>是具有 <span class="highlight">n 个顶点</span>的图,它不包含大小为 s 的团,也不包含大小为 t 的独立集。</p>
1811
+ <p><strong>拉姆齐定理</strong>表明,对于给定的 s 和 t,Ramsey(s,t) 图的数量是有限的。满足这种图存在的最小顶点数称为<strong>拉姆齐数 R(s,t)</strong>。</p>
1812
+ <p>对于给定的 s 和 t,当节点数量 n 增加时,存在一个<span class="highlight">临界数量</span>——一旦节点数超过这个临界值,大小为 s 的团或大小为 t 的独立集就<strong>一定</strong>存在于任意图中。寻找 Ramsey 图就是在寻找这个临界节点数:在这个节点数量下,我们恰好至少能找到一个很特殊的图,它既不包含大小为 s 的团,也不包含大小为 t 的独立集。</p>
1813
+ <div class="significance">
1814
+ <strong>${lightbulbIcon}重要意义:</strong>如果我们能有一种算法提前知道拉姆齐数的具体值,就相当于知道系统中某种子结构在什么时候<strong>必然</strong>开始存在。这样就不用保持过量的节点,从而在网络设计、分布式系统等应用中节省成本。
1815
+ </div>
1816
+ <p>找到所有这样的图,甚至确定它们存在的最大 n,都是组合数学中的著名难题。大多数拉姆齐数仍然未知——我们只知道它们的上界和下界。</p>
1817
+ <div class="challenge">
1818
+ <strong>${trophyIcon}开放挑战:</strong>找到一个 <span class="highlight">43 顶点的 Ramsey(5,5) 图</span>!<br><br>
1819
+ 目前所有 42 顶点的 Ramsey(5,5) 图都已被找到,但不确定是否存在 43 顶点的图。R(5,5) 的下界自 <strong>1989 年</strong>以来就没有被改进过。只要找到一个这样的图,就是这个领域 35 年来的重大突破!
1820
+ </div>
1821
+ <p>有关 Ramsey 图的最新研究,请参见 <strong>Radziszowski</strong> 的动态综述,持续更新刊登于<a href="https://www.combinatorics.org" target="_blank" style="color: var(--accent-blue);">电子组合学期刊</a>。</p>
1822
+ `
1823
+ };
1824
+
1825
+ const ramseyTable = [
1826
+ ['s\\t', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
1827
+ ['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],
1828
+ ['2', '-', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
1829
+ ['3', '-', '-', '6', '9', '14', '18', '23', '28', '36', '40-41'],
1830
+ ['4', '-', '-', '-', '18', '25', '36-40', '49-58', '59-79', '73-106', '92-136'],
1831
+ ['5', '-', '-', '-', '-', '43-48', '59-85', '80-133', '101-194', '133-282', '149-381'],
1832
+ ['6', '-', '-', '-', '-', '-', '102-161', '115-273', '134-427', '183-656', '204-949'],
1833
+ ['7', '-', '-', '-', '-', '-', '-', '205-497', '219-840', '252-1379', '292-2134'],
1834
+ ['8', '-', '-', '-', '-', '-', '-', '-', '282-1532', '329-2683', '343-4432'],
1835
+ ['9', '-', '-', '-', '-', '-', '-', '-', '-', '565-5366', '581-9797'],
1836
+ ['10', '-', '-', '-', '-', '-', '-', '-', '-', '-', '798-17730']
1837
+ ];
1838
+
1839
+ function generateProgressTable() {
1840
+ let html = '<table class="ramsey-table"><thead><tr>';
1841
+ ramseyTable[0].forEach(h => html += `<th>${h}</th>`);
1842
+ html += '</tr></thead><tbody>';
1843
+
1844
+ for (let i = 1; i < ramseyTable.length; i++) {
1845
+ html += '<tr>';
1846
+ ramseyTable[i].forEach((cell, j) => {
1847
+ if (j === 0) {
1848
+ html += `<th>${cell}</th>`;
1849
+ } else if (cell === '-') {
1850
+ html += `<td class="trivial">-</td>`;
1851
+ } else if (cell.includes('-')) {
1852
+ html += `<td class="range">${cell}</td>`;
1853
+ } else {
1854
+ html += `<td class="exact">${cell}</td>`;
1855
+ }
1856
+ });
1857
+ html += '</tr>';
1858
+ }
1859
+
1860
+ html += '</tbody></table>';
1861
+ html += `<div class="table-legend">
1862
+ <div class="table-legend-item"><div class="legend-box exact"></div><span data-i18n="exactValue">${t('exactValue')}</span></div>
1863
+ <div class="table-legend-item"><div class="legend-box range"></div><span data-i18n="rangeValue">${t('rangeValue')}</span></div>
1864
+ </div>`;
1865
+ return html;
1866
+ }
1867
+
1868
+ function openModal(modalId) {
1869
+ const modal = document.getElementById(modalId);
1870
+ if (modalId === 'introModal') {
1871
+ document.getElementById('introBody').innerHTML = introContent[currentLang];
1872
+ } else if (modalId === 'progressModal') {
1873
+ document.getElementById('progressBody').innerHTML = generateProgressTable();
1874
+ }
1875
+ modal.classList.add('show');
1876
+ }
1877
+
1878
+ function closeModal(modal) {
1879
+ modal.classList.remove('show');
1880
+ }
1881
+
1882
+ // Modal event listeners
1883
+ document.getElementById('introBtn').addEventListener('click', () => openModal('introModal'));
1884
+ document.getElementById('progressBtn').addEventListener('click', () => openModal('progressModal'));
1885
+
1886
+ document.querySelectorAll('.modal-overlay, .modal-close').forEach(el => {
1887
+ el.addEventListener('click', (e) => {
1888
+ const modal = e.target.closest('.modal');
1889
+ if (modal) closeModal(modal);
1890
+ });
1891
+ });
1892
+
1893
+ document.addEventListener('keydown', e => {
1894
+ if (e.key === 'Escape') {
1895
+ document.querySelectorAll('.modal.show').forEach(m => closeModal(m));
1896
+ }
1897
+ });
1898
+
1899
+ // Init
1900
+ initSelectors();
1901
+ // Apply saved language
1902
+ setLanguage(currentLang);
1903
+ </script>
1904
+ </body>
1905
+ </html>