forked from Shad0wwa1ker/OpenICLR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1852 lines (1608 loc) · 66.8 KB
/
Copy pathindex.html
File metadata and controls
1852 lines (1608 loc) · 66.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ICLR 论文-作者-审稿人关系图</title>
<script type="text/javascript" src="https://unpkg.com/vis-network/standalone/umd/vis-network.min.js"></script>
<script src="load_chunked_json.js"></script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1800px;
margin: 0 auto;
background: white;
border-radius: 15px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
text-align: center;
}
.header h1 {
font-size: 2.5em;
margin-bottom: 10px;
}
.header p {
font-size: 1.1em;
opacity: 0.9;
}
.controls {
padding: 20px 30px;
background: #f8f9fa;
border-bottom: 1px solid #dee2e6;
display: flex;
flex-wrap: wrap;
gap: 15px;
align-items: center;
}
.control-group {
display: flex;
align-items: center;
gap: 10px;
}
.control-group label {
font-weight: 600;
color: #495057;
}
.control-group input,
.control-group select,
.control-group button {
padding: 8px 15px;
border: 2px solid #dee2e6;
border-radius: 5px;
font-size: 14px;
transition: all 0.3s;
}
.control-group input:focus,
.control-group select:focus {
outline: none;
border-color: #667eea;
}
.control-group button {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
cursor: pointer;
font-weight: 600;
}
.control-group button:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}
.control-group button:active {
transform: translateY(0);
}
.delete-btn {
background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%) !important;
margin-top: 10px;
width: 100%;
}
.delete-btn:hover {
background: linear-gradient(135deg, #e53935 0%, #c62828 100%) !important;
}
/* 优化渲染性能 */
.container {
contain: layout style paint;
}
.stats {
contain: layout style;
}
.control-group button:disabled {
background: #ccc;
cursor: not-allowed;
transform: none;
}
.search-input-group {
display: flex;
gap: 10px;
flex: 1;
min-width: 300px;
}
.search-input-group input {
flex: 1;
}
.stats {
display: flex;
gap: 20px;
flex-wrap: wrap;
margin-left: auto;
}
.stat-item {
background: white;
padding: 10px 20px;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.stat-item .label {
font-size: 0.85em;
color: #6c757d;
margin-bottom: 5px;
}
.stat-item .value {
font-size: 1.5em;
font-weight: bold;
color: #667eea;
}
#network {
width: 100%;
height: 700px;
background: #f8f9fa;
border: 1px solid #dee2e6;
position: relative;
/* 启用硬件加速 */
transform: translateZ(0);
will-change: contents;
}
.loading-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(248, 249, 250, 0.9);
display: none;
align-items: center;
justify-content: center;
z-index: 1000;
flex-direction: column;
gap: 15px;
}
.loading-overlay.active {
display: flex;
}
.spinner {
width: 40px;
height: 40px;
border: 4px solid #dee2e6;
border-top-color: #667eea;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.loading-text {
color: #495057;
font-size: 14px;
}
.info-panel {
padding: 20px 30px;
background: #f8f9fa;
border-top: 1px solid #dee2e6;
display: none;
}
.info-panel.active {
display: block;
}
.info-panel h3 {
color: #495057;
margin-bottom: 15px;
font-size: 1.3em;
}
.info-item {
background: white;
padding: 15px;
border-radius: 8px;
margin-bottom: 10px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}
.info-item strong {
color: #667eea;
display: inline-block;
min-width: 120px;
}
.review-content {
background: #fff3cd;
border-left: 4px solid #ffc107;
padding: 15px;
margin: 10px 0;
border-radius: 5px;
}
.review-section {
margin-bottom: 15px;
}
.review-section-title {
font-weight: 600;
color: #856404;
margin-bottom: 5px;
font-size: 0.9em;
}
.review-section-content {
color: #495057;
line-height: 1.6;
white-space: pre-wrap;
word-wrap: break-word;
}
.review-rating {
display: inline-block;
background: #ff6b6b;
color: white;
padding: 3px 10px;
border-radius: 12px;
font-weight: 600;
font-size: 0.9em;
margin-bottom: 10px;
}
.review-search-result {
padding: 12px;
border-bottom: 1px solid #f0f0f0;
cursor: pointer;
transition: background 0.2s;
}
.review-search-result:hover {
background: #f8f9fa;
}
.review-search-result-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
}
.review-search-result-rating {
background: #ff6b6b;
color: white;
padding: 2px 8px;
border-radius: 10px;
font-size: 0.85em;
font-weight: 600;
}
.review-search-result-preview {
color: #6c757d;
font-size: 0.9em;
line-height: 1.4;
max-height: 60px;
overflow: hidden;
text-overflow: ellipsis;
}
.review-search-result-meta {
font-size: 0.8em;
color: #999;
margin-top: 5px;
}
.legend {
display: flex;
gap: 20px;
flex-wrap: wrap;
margin-top: 10px;
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
}
.legend-color {
width: 20px;
height: 20px;
border-radius: 50%;
}
.legend-color.paper {
background: #4CAF50;
}
.legend-color.author {
background: #2196F3;
}
.legend-color.reviewer {
background: #FF9800;
}
.legend-line {
width: 30px;
height: 3px;
}
.legend-line.submission {
background: #2B7CE9;
}
.legend-line.review {
background: #FF6B6B;
}
.hint {
text-align: center;
padding: 20px;
color: #6c757d;
font-style: italic;
}
.search-results {
position: absolute;
top: 100%;
left: 0;
right: 0;
background: white;
border: 1px solid #dee2e6;
border-top: none;
border-radius: 0 0 5px 5px;
max-height: 300px;
overflow-y: auto;
z-index: 1000;
display: none;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.search-results.active {
display: block;
}
.search-result-item {
padding: 10px 15px;
cursor: pointer;
border-bottom: 1px solid #f0f0f0;
transition: background 0.2s;
}
.search-result-item:hover {
background: #f8f9fa;
}
.search-result-item:last-child {
border-bottom: none;
}
.search-result-label {
font-weight: 600;
color: #495057;
}
.search-result-type {
font-size: 0.85em;
color: #6c757d;
margin-left: 10px;
}
.search-result-score {
float: right;
font-size: 0.8em;
color: #667eea;
font-weight: 600;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>📊 ICLR 论文-作者-审稿人关系图</h1>
<p>动态可视化论文投稿和审稿关系网络 - 按需加载</p>
</div>
<div class="controls">
<div class="control-group search-input-group" style="position: relative;">
<input type="text" id="searchInput" placeholder="输入投稿号/作者名称/审稿人代号... (支持模糊搜索)" autocomplete="off">
<button onclick="addNodeBySearch()">添加节点</button>
<label style="display: flex; align-items: center; gap: 5px; white-space: nowrap;">
<input type="checkbox" id="fuzzySearchEnabled" checked style="width: auto; margin: 0;">
<span style="font-size: 12px;">模糊搜索</span>
</label>
<div class="search-results" id="searchResults"></div>
</div>
<div class="control-group search-input-group" style="position: relative; margin-top: 10px;">
<input type="text" id="reviewSearchInput" placeholder="搜索评论内容... (支持模糊搜索)" autocomplete="off">
<button onclick="searchReviews()">搜索评论</button>
<div class="search-results" id="reviewSearchResults"></div>
</div>
<div class="control-group">
<button onclick="clearGraph()">清空图表</button>
<button onclick="deleteSelectedNodes()" id="deleteBtn" disabled style="background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);">删除选中节点</button>
<button onclick="fitNetwork()">适应窗口</button>
</div>
<div class="stats">
<div class="stat-item">
<div class="label">已加载节点</div>
<div class="value" id="statNodes">0</div>
</div>
<div class="stat-item">
<div class="label">已加载边</div>
<div class="value" id="statEdges">0</div>
</div>
</div>
</div>
<div class="legend" style="padding: 15px 30px; background: #f8f9fa; border-bottom: 1px solid #dee2e6;">
<div class="legend-item">
<div class="legend-color paper"></div>
<span>论文节点</span>
</div>
<div class="legend-item">
<div class="legend-color author"></div>
<span>作者节点</span>
</div>
<div class="legend-item">
<div class="legend-color reviewer"></div>
<span>审稿人节点</span>
</div>
<div class="legend-item">
<div class="legend-line submission"></div>
<span>投稿关系</span>
</div>
<div class="legend-item">
<div class="legend-line review"></div>
<span>审稿关系</span>
</div>
</div>
<div id="network" style="position: relative;">
<div class="loading-overlay" id="loadingOverlay">
<div class="spinner"></div>
<div class="loading-text" id="loadingText">加载中...</div>
</div>
</div>
<div class="hint" id="hintText">💡 提示: 在搜索框中输入投稿号、作者名称或审稿人代号,然后点击"添加节点"开始探索</div>
<div class="info-panel" id="infoPanel">
<h3>节点信息</h3>
<div id="infoContent"></div>
</div>
</div>
<script>
// 全局变量
let network = null;
let nodes = new vis.DataSet([]);
let edges = new vis.DataSet([]);
let graphIndex = null;
let graphData = null; // 完整的图数据(包含评论内容)
let loadedNodeIds = new Set(); // 已加载的节点ID
let jsonLoader = new ChunkedJSONLoader(''); // 分块JSON加载器
let selectedNodeIds = new Set(); // 选中的节点ID
// 性能优化:批量更新队列
let updateQueue = {
nodes: new Set(),
edges: new Set(),
timeout: null
};
// 防抖函数
function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
// 节流函数
function throttle(func, limit) {
let inThrottle;
return function(...args) {
if (!inThrottle) {
func.apply(this, args);
inThrottle = true;
setTimeout(() => inThrottle = false, limit);
}
};
}
// 计算编辑距离(Levenshtein距离)
function levenshteinDistance(str1, str2) {
const len1 = str1.length;
const len2 = str2.length;
// 创建矩阵
const matrix = Array(len1 + 1).fill(null).map(() => Array(len2 + 1).fill(0));
// 初始化第一行和第一列
for (let i = 0; i <= len1; i++) matrix[i][0] = i;
for (let j = 0; j <= len2; j++) matrix[0][j] = j;
// 填充矩阵
for (let i = 1; i <= len1; i++) {
for (let j = 1; j <= len2; j++) {
const cost = str1[i - 1] === str2[j - 1] ? 0 : 1;
matrix[i][j] = Math.min(
matrix[i - 1][j] + 1, // 删除
matrix[i][j - 1] + 1, // 插入
matrix[i - 1][j - 1] + cost // 替换
);
}
}
return matrix[len1][len2];
}
// 计算相似度(0-1之间,1表示完全相同)
function similarity(str1, str2) {
const maxLen = Math.max(str1.length, str2.length);
if (maxLen === 0) return 1;
const distance = levenshteinDistance(str1.toLowerCase(), str2.toLowerCase());
return 1 - (distance / maxLen);
}
// 模糊搜索函数(返回带评分的结果)
function fuzzySearch(query, labels, threshold = 0.6, maxResults = 50) {
const queryLower = query.toLowerCase();
const results = [];
// 如果查询太短,只做精确和包含匹配
const useFuzzy = queryLower.length >= 3;
for (const [label, ids] of Object.entries(labels)) {
const labelLower = label.toLowerCase();
// 1. 精确匹配(最高优先级)
if (labelLower === queryLower) {
ids.forEach(id => {
results.push({ id, score: 1.0, matchType: 'exact', label });
});
continue;
}
// 2. 包含匹配
if (labelLower.includes(queryLower)) {
const score = 0.9 * (queryLower.length / labelLower.length);
ids.forEach(id => {
results.push({ id, score, matchType: 'contains', label });
});
continue;
}
// 3. 开头匹配
if (labelLower.startsWith(queryLower)) {
ids.forEach(id => {
results.push({ id, score: 0.85, matchType: 'starts', label });
});
continue;
}
// 4. 结尾匹配
if (labelLower.endsWith(queryLower)) {
ids.forEach(id => {
results.push({ id, score: 0.8, matchType: 'ends', label });
});
continue;
}
// 5. 单词匹配(按空格分割)
const queryWords = queryLower.split(/\s+/).filter(w => w.length > 0);
const labelWords = labelLower.split(/\s+/).filter(w => w.length > 0);
if (queryWords.length > 0) {
let wordMatches = 0;
for (const qWord of queryWords) {
for (const lWord of labelWords) {
if (lWord.includes(qWord) || qWord.includes(lWord)) {
wordMatches++;
break;
}
}
}
if (wordMatches > 0) {
const score = (wordMatches / queryWords.length) * 0.7;
ids.forEach(id => {
results.push({ id, score, matchType: 'words', label });
});
continue;
}
}
// 6. 模糊匹配(编辑距离)- 只在查询长度>=3时使用
if (useFuzzy) {
const sim = similarity(queryLower, labelLower);
if (sim >= threshold) {
ids.forEach(id => {
results.push({ id, score: sim * 0.6, matchType: 'fuzzy', label });
});
}
}
}
// 去重并按分数排序
const uniqueResults = new Map();
for (const result of results) {
if (!uniqueResults.has(result.id) || uniqueResults.get(result.id).score < result.score) {
uniqueResults.set(result.id, result);
}
}
// 转换为数组并按分数降序排序
const sortedResults = Array.from(uniqueResults.values())
.sort((a, b) => b.score - a.score)
.slice(0, maxResults);
return sortedResults;
}
// 显示/隐藏加载状态
function showLoading(text = '加载中...') {
const overlay = document.getElementById('loadingOverlay');
const loadingText = document.getElementById('loadingText');
if (overlay && loadingText) {
loadingText.textContent = text;
overlay.classList.add('active');
}
}
function hideLoading() {
const overlay = document.getElementById('loadingOverlay');
if (overlay) {
overlay.classList.remove('active');
}
}
// 更新统计信息(使用节流优化)
const updateStats = throttle(function() {
requestAnimationFrame(() => {
const nodesCount = nodes.length;
const edgesCount = edges.length;
const nodesEl = document.getElementById('statNodes');
const edgesEl = document.getElementById('statEdges');
if (nodesEl) nodesEl.textContent = nodesCount;
if (edgesEl) edgesEl.textContent = edgesCount;
});
}, 100);
// 节点颜色配置
const nodeColors = {
'paper': { background: '#4CAF50', border: '#2E7D32', highlight: { background: '#66BB6A', border: '#2E7D32' } },
'author': { background: '#2196F3', border: '#1565C0', highlight: { background: '#64B5F6', border: '#1565C0' } },
'reviewer': { background: '#FF9800', border: '#E65100', highlight: { background: '#FFB74D', border: '#E65100' } }
};
// 加载索引数据
async function loadIndex() {
try {
showLoading('正在加载数据索引...');
// 使用分块加载器,自动检测是否需要分块加载
graphIndex = await jsonLoader.loadJSON('graph_index.json');
console.log('索引加载成功');
// 尝试加载完整的图数据(包含评论内容)
try {
graphData = await jsonLoader.loadJSON('graph_data.json');
console.log('图数据加载成功');
} catch (e) {
console.warn('无法加载 graph_data.json,评论内容可能无法显示:', e);
}
hideLoading();
} catch (error) {
console.error('加载索引失败:', error);
hideLoading();
alert('无法加载索引文件。请先运行 build_index.py 生成 graph_index.json');
}
}
// 初始化网络
function initializeNetwork() {
const container = document.getElementById('network');
const data = {
nodes: nodes,
edges: edges
};
const options = {
nodes: {
borderWidth: 2,
shadow: {
enabled: false // 禁用阴影提升性能
},
font: {
size: 12,
face: 'Arial'
},
shape: 'dot',
chosen: {
node: function(values, id, selected, hovering) {
// 优化选中效果
if (hovering || selected) {
values.borderWidth = 3;
}
}
}
},
edges: {
shadow: {
enabled: false // 禁用阴影提升性能
},
smooth: {
type: 'continuous',
roundness: 0.5,
forceDirection: 'none' // 优化平滑算法
},
arrows: {
to: {
enabled: true,
scaleFactor: 0.8
}
}
},
physics: {
enabled: true,
stabilization: {
enabled: true,
iterations: 50, // 减少迭代次数,提升初始加载速度
fit: true,
updateInterval: 25 // 更频繁的更新,但减少总迭代
},
barnesHut: {
gravitationalConstant: -3000, // 优化力场
centralGravity: 0.05,
springLength: 150,
springConstant: 0.05,
damping: 0.15, // 增加阻尼,更快稳定
avoidOverlap: 0.8
},
adaptiveTimestep: true, // 自适应时间步长
maxVelocity: 50, // 限制最大速度
minVelocity: 0.01, // 最小速度阈值
solver: 'barnesHut' // 使用高效的Barnes-Hut算法
},
interaction: {
hover: true,
tooltipDelay: 200, // 增加延迟,减少频繁触发
zoomView: true,
dragView: true,
selectConnectedEdges: false, // 禁用自动选择连接边,提升性能
hideEdgesOnDrag: false, // 拖拽时保持边显示
hideEdgesOnZoom: false // 缩放时保持边显示
},
layout: {
improvedLayout: true, // 启用改进的布局算法
hierarchical: {
enabled: false
}
},
configure: {
enabled: false // 禁用配置面板
}
};
network = new vis.Network(container, data, options);
// 稳定化完成事件
network.once('stabilizationEnd', function() {
console.log('网络稳定化完成');
hideLoading();
});
// 稳定化进度事件(可选,用于显示进度)
network.on('stabilizationProgress', function(params) {
if (params.iterations % 10 === 0) {
console.log(`稳定化进度: ${params.iterations}/${params.total}`);
}
});
// 节点点击事件 - 展开节点(使用节流优化)
network.on('click', throttle(function(params) {
if (params.nodes.length > 0) {
const nodeId = params.nodes[0];
// 使用 requestAnimationFrame 优化
requestAnimationFrame(() => {
expandNode(nodeId);
showNodeInfo(nodeId);
});
} else if (params.edges.length > 0) {
// 点击边,显示评论内容
const edgeId = params.edges[0];
showEdgeInfo(edgeId);
} else {
hideNodeInfo();
}
}, 200));
// 节点选择事件
network.on('selectNode', function(params) {
selectedNodeIds.clear();
params.nodes.forEach(nodeId => selectedNodeIds.add(nodeId));
updateDeleteButton();
});
// 节点取消选择事件
network.on('deselectNode', function(params) {
params.nodes.forEach(nodeId => selectedNodeIds.delete(nodeId));
updateDeleteButton();
});
// 点击空白处取消选择
network.on('click', function(params) {
if (params.nodes.length === 0 && params.edges.length === 0) {
selectedNodeIds.clear();
updateDeleteButton();
}
});
// 双击节点时聚焦
network.on('doubleClick', function(params) {
if (params.nodes.length > 0) {
network.focus(params.nodes[0], {
scale: 1.5,
animation: {
duration: 300,
easingFunction: 'easeInOutQuad'
}
});
}
});
// 拖拽开始和结束事件(优化性能)
let isDragging = false;
network.on('dragStart', function() {
isDragging = true;
// 拖拽时临时禁用物理引擎
network.setOptions({ physics: { enabled: false } });
});
network.on('dragEnd', function() {
isDragging = false;
// 拖拽结束后重新启用物理引擎
network.setOptions({ physics: { enabled: true } });
});
// 缩放事件优化(使用防抖)
network.on('zoom', debounce(function(params) {
// 缩放时可以调整节点大小
if (params.scale < 0.5) {
// 缩小视图时隐藏标签
network.setOptions({
nodes: { font: { size: 0 } }
});
} else {
network.setOptions({
nodes: { font: { size: 12 } }
});
}
}, 100));
updateStats();
}
// 根据搜索添加节点(优化性能)
function addNodeBySearch() {
let query = document.getElementById('searchInput').value.trim();
if (!query) {
alert('请输入搜索内容');
return;
}
if (!graphIndex) {
alert('索引未加载,请刷新页面重试');
return;
}
showLoading('搜索节点...');
// 使用 requestAnimationFrame 优化搜索性能
requestAnimationFrame(() => {
// 如果输入是纯数字,自动转换为投稿号格式
if (/^\d+$/.test(query)) {
const submissionNumber = query;
// 尝试多种投稿号格式(按常见格式顺序尝试)
const possibleIds = [
`ICLR.cc/2026/Conference/Submission${submissionNumber}`,
`Submission${submissionNumber}`,
`ICLR.cc/2026/Conference/Submission${submissionNumber.padStart(4, '0')}` // 带前导零的格式
];
// 查找匹配的投稿号
let found = false;
for (const possibleId of possibleIds) {
if (graphIndex.nodes_by_id[possibleId]) {
query = possibleId;
found = true;
break;
}
}
// 如果直接匹配失败,尝试在所有节点ID中搜索包含该数字的投稿号
if (!found) {
const searchPattern = new RegExp(`Submission${submissionNumber}(?:\\D|$)`);
for (const nodeId of Object.keys(graphIndex.nodes_by_id)) {
if (searchPattern.test(nodeId)) {
query = nodeId;
found = true;
break;
}
}
}
}
// 尝试多种搜索方式
let nodeIds = [];
let searchMethod = '';
// 1. 直接按ID搜索(精确匹配)
if (graphIndex.nodes_by_id[query]) {
nodeIds = [query];
searchMethod = '精确ID匹配';
}
// 2. 精确标签匹配
else if (graphIndex.nodes_by_label[query.toLowerCase()]) {
nodeIds = graphIndex.nodes_by_label[query.toLowerCase()];
searchMethod = '精确标签匹配';
}
// 3. 包含匹配和模糊搜索
else {
const queryLower = query.toLowerCase();
const maxResults = 50;
const fuzzyEnabled = document.getElementById('fuzzySearchEnabled')?.checked !== false;
// 先尝试快速包含匹配
const quickResults = [];
for (const [label, ids] of Object.entries(graphIndex.nodes_by_label)) {
if (quickResults.length >= maxResults) break;
if (label.includes(queryLower)) {
quickResults.push(...ids);
}
}