Implemented a "Stiff" layout mode by interleaving constraint enforcement directly into the force-directed simulation loop. This makes the graph feel like a network of rigid rods rather than rubber bands, which encourages emergent geometry (symmetries, grids, rings) and significantly reduces overlaps.
- Constraint Interleaving:
enforceEdgeConstraintsis now called inside the simulation loop (every tick), not just at the end. - Strictness: Edges now strictly target the ideal
targetLinkDistance(orr1+r2if that is larger), rather than allowing a "slop" range. - In-Loop Collision Resolution:
resolveOverlapsis also run inside the loop (every other tick), ensuring nodes don't pass through each other easily. - Stiffness Parameter: Added
stiffness(default0.6) toFORCE_LAYOUT_DEFAULTS. A higher value (e.g., 0.8) makes the graph very rigid; a lower value (0.2) makes it organic/floppy.
In unweighted graphs, geometric patterns (hexagons, triangles, grids) emerge when all edge lengths are uniform. By enforcing rigid length constraints iteratively, the layout algorithm is forced to find a configuration where all edges are as close to length