This repository was archived by the owner on Jun 18, 2026. It is now read-only.
Commit 37f7cb1
committed
perf: cache neighbor sets in CliqueAnalyzer Bron-Kerbosch
getNeighbors() was creating a new LinkedHashSet copy of each
vertex's adjacency list on every call. During Bron-Kerbosch
recursion and pivot selection, this is called O(V * recursion
depth) times — for dense graphs with many cliques, the
temporary allocation pressure dominates runtime.
Fix: build a HashMap<String, Set<String>> neighbor cache once
at the start of compute(), before entering recursion. The
recursive bronKerbosch(), choosePivot(), and countIntersection()
methods now read from this cache with O(1) lookups instead of
allocating. Defensive fallback retained for vertices not in
cache (should never trigger after compute() initialisation).1 parent d753d2e commit 37f7cb1
1 file changed
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
71 | 87 | | |
72 | 88 | | |
73 | 89 | | |
| |||
166 | 182 | | |
167 | 183 | | |
168 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
169 | 189 | | |
170 | 190 | | |
171 | 191 | | |
| |||
0 commit comments