Commit 2e5b7d8
committed
Fixes #207 | faithful Eades (1984) Spring Embedder implementation
The previous implementation deviated from Eades (1984) in
ways that caused poor layouts and unnecessary slowness.
Visual quality fixes:
- Remove f_rep=0 cutoff for dist > 2*optimalDistance — this was the
primary cause of node clustering; all pairs now repel unconditionally
- Fix naturalLength (c2): was 2.5*computeOptimalDistance (~297px for
N=100), now canvasMinDimension/sqrt(V) (~80px) — the correct
pixel-space equivalent of Eades' unit-square formulation; the old
value made log(d/c2)≈0 for most pairs, nearly disabling attraction
- Revert c_rep (c3) to 1.0 per Eades (1984); revert c4_init to 0.1
- Add mild linear cooling schedule (c4: 0.10→0.01) to help settling
- Add displacement cap (canvasMinDimension*0.05) to prevent
early-iteration force explosions from near-coincident nodes
- Add early-exit convergence when maxDisp < epsilon (2.0px)
- Reduce maxIterations from 500 to 300 in slotLayoutSpringEmbedder()
- Warn user when N>30 (Eades' own stated limitation of the algorithm)
Performance fixes:
- Pre-cache adjacency into QSet<QPair<int,int>> before iteration loop;
replaces O(log N) edgeExists() calls in the O(N²) inner loop
- Inline Eades force math directly; eliminates per-call QString dispatch
- Cache vertex numbers to local const int before inner loop
- Emit setNodePos in a single bulk pass after the iteration loop1 parent 7427fde commit 2e5b7d8
File tree
3 files changed
+282
-137
lines changed- src
- graph/layouts
3 files changed
+282
-137
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1079 | 1079 | | |
1080 | 1080 | | |
1081 | 1081 | | |
1082 | | - | |
1083 | | - | |
1084 | 1082 | | |
1085 | 1083 | | |
1086 | 1084 | | |
| |||
1122 | 1120 | | |
1123 | 1121 | | |
1124 | 1122 | | |
1125 | | - | |
| 1123 | + | |
1126 | 1124 | | |
1127 | 1125 | | |
1128 | 1126 | | |
| |||
1243 | 1241 | | |
1244 | 1242 | | |
1245 | 1243 | | |
| 1244 | + | |
| 1245 | + | |
1246 | 1246 | | |
1247 | 1247 | | |
1248 | 1248 | | |
| |||
0 commit comments