Skip to content

Commit 2e5b7d8

Browse files
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 loop
1 parent 7427fde commit 2e5b7d8

File tree

3 files changed

+282
-137
lines changed

3 files changed

+282
-137
lines changed

src/graph.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,8 +1079,6 @@ public slots:
10791079

10801080
void layoutRandom();
10811081

1082-
void layoutRandomInMemory();
1083-
10841082
void layoutRadialRandom(const bool &guides = true);
10851083

10861084
void layoutCircular(const double &x0,
@@ -1122,7 +1120,7 @@ public slots:
11221120
const qreal &dist,
11231121
const qreal &optimalDistance);
11241122

1125-
void layoutForceDirected_Eades_moveNodes(const qreal &c4);
1123+
qreal layoutForceDirected_Eades_moveNodes(const qreal &c4);
11261124

11271125
void layoutForceDirected_FR_moveNodes(const qreal &temperature);
11281126

@@ -1243,6 +1241,8 @@ public slots:
12431241
H_StrToInt &discreteClasses,
12441242
int &classes, int name);
12451243

1244+
void layoutRandomInMemory();
1245+
12461246
VList m_graph; // List of pointers to the vertices. Each vertex stores all info: links, colors, etc
12471247

12481248
Parser *file_parser; // Our file loader threaded class.

0 commit comments

Comments
 (0)