@graphty/layout / index / FruchtermanReingoldSimulation
Class: FruchtermanReingoldSimulation
Defined in: simulation/fruchterman-reingold.ts:103
The steppable Fruchterman-Reingold layout over the owner's stride-3 scene-unit array (design 9.3): load() takes a snapshot and the array (NaN rows are seeded in [0, 1) layout units, design 7.20), step(k) runs up to k iterations of the legacy loop body and writes every free node back in scene units, settled follows design 7.17, setFixed / setPosition / reheat follow design 7.12 and D8. maxInFlight is ignored (a CPU simulation is synchronous).
Implements
Constructors
Constructor
new FruchtermanReingoldSimulation(
options?):FruchtermanReingoldSimulation
Defined in: simulation/fruchterman-reingold.ts:154
Stores the resolved options; nothing is allocated until load().
Parameters
options?
FruchtermanReingoldOptions = {}
design 9.3 FruchtermanReingoldOptions (every field optional)
Returns
FruchtermanReingoldSimulation
Accessors
iterationsDone
Get Signature
get iterationsDone():
number
Defined in: simulation/fruchterman-reingold.ts:232
The iteration index, which is also the temperature index under linear cooling.
Returns
number
the iterations run since load(), or since the last reheat() plus its 70% restart point (linear) or since the last reheat() (adaptive)
meanDisplacement
Get Signature
get meanDisplacement():
number
Defined in: simulation/fruchterman-reingold.ts:248
The last iteration's movement.
Returns
number
the mean displacement of the free nodes in layout units (0 before the first iteration)
rmsRadius
Get Signature
get rmsRadius():
number
Defined in: simulation/fruchterman-reingold.ts:256
The settle normaliser of design 7.17.
Returns
number
the RMS radius about the centroid in layout units after the last iteration
settled
Get Signature
get settled():
boolean
Defined in: simulation/fruchterman-reingold.ts:223
The settle flag of design 7.17.
Returns
boolean
true at the iteration budget or after settleWindow quiet iterations; true for an empty graph
Implementation of
settledCount
Get Signature
get settledCount():
number
Defined in: simulation/fruchterman-reingold.ts:240
The settle counter of design 7.17.
Returns
number
the consecutive iterations whose mean free-node displacement was <= settleThreshold * rmsRadius
temperature
Get Signature
get temperature():
number
Defined in: simulation/fruchterman-reingold.ts:265
The cooling schedule's current value.
Returns
number
the temperature in layout units per iteration: linear, the next iteration's; adaptive, the one the last iteration moved with (the next iteration's controller update may change it)
Methods
dispose()
dispose():
void
Defined in: simulation/fruchterman-reingold.ts:435
Releases the scratch arrays; every later call but dispose() throws.
Returns
void
Implementation of
load()
load(
snapshot,positions):void
Defined in: simulation/fruchterman-reingold.ts:279
Binds a snapshot and the owner's array (design 7.19 load): validates (undirected, 3 * nodeCount entries), seeds the NaN rows in [0, 1) layout units with the LCG (design 7.20 "initial positions"), converts the scene array into the internal layout-unit array (v - center) / scale (z forced to 0 in 2D), resolves k and the temperature schedule, applies the fixed option (a mask, a bool node column by name, or the role-fixed bool column when the option is null; pins set by setFixed survive a same-size reload without an option and are cleared when n changes, design 7.12), resets the settle statistics and restarts at iteration 0.
Parameters
snapshot
GraphSnapshot
an undirected snapshot
positions
F32
the owner's stride-3 scene-unit array, length 3 * nodeCount, read and written in place
Returns
void
Implementation of
reheat()
reheat():
void
Defined in: simulation/fruchterman-reingold.ts:418
Reheats (D8, design 7.20): the settle window restarts. Linear cooling: the iteration index becomes floor(0.7 * iterations), so the run continues at a small temperature for the remaining 30% of the budget. Adaptive cooling: the budget restarts at 0 and the controller at the start temperature, as the GPU simulation's reheat() does. Nothing else changes. Allowed before load().
Returns
void
setFixed()
setFixed(
mask):void
Defined in: simulation/fruchterman-reingold.ts:360
Replaces the pinned set (design 7.12): the mask needs ceil(n / 32) words; the bits are copied; the simulation reheats only when a bit went 1 -> 0 (an unpin); adding pins never reheats.
Parameters
mask
U32
the NodeMask (LSB-first words, the bool-column layout)
Returns
void
Implementation of
setPosition()
setPosition(
index,x,y,z):void
Defined in: simulation/fruchterman-reingold.ts:392
A drag (design 7.12): writes the scene position into the owner's array at once and into the internal layout position (v - center) / scale (z forced to 0 in 2D), then reheat().
Parameters
index
number
the node index (< n)
x
number
scene x
y
number
scene y
z
number
scene z (ignored by the layout in 2D)
Returns
void
Implementation of
step()
step(
iterations?):void
Defined in: simulation/fruchterman-reingold.ts:334
Runs up to iterations iterations of the legacy loop body (design 7.19 step): throws before load() and after dispose(); returns at once when settled; stops early when the budget or the settle window is reached, so the simulation never runs an iteration while settled; then writes every FREE node back to the owner's array in scene units (fixed rows are never written: their scene value is the owner's).
Parameters
iterations?
number = ...
the batch size k (default options.iterationsPerStep, default 1)
Returns
void