Skip to main content

Function: springLayoutStep()

springLayoutStep(vertices, edges, positions, params): SpringStepResult

Defined in: src/mobjects/graph/layoutAlgorithms.ts:165

Advance the spring (force-directed) simulation by one step.

This is one Fruchterman-Reingold iteration. It computes repulsive forces between every pair of vertices and attractive forces along the edges. Then it moves each vertex by its net force, limited by the temperature. It returns a new positions map and the cooled temperature, so the caller holds the state.

The function is pure. It reads positions and returns new positions. It does not change the input. Run it iterations times to reproduce computeSpringLayout.

Parameters​

vertices​

VertexId[]

edges​

EdgeTuple[]

positions​

Map<VertexId, SpringPoint>

params​

SpringStepParams

Returns​

SpringStepResult