apaGraph.Layout.ForceDirected.AllParams(Edges, IsWeighted, SpringLength, TimeStep, RepulsionForce, AttractionConstant, Damping, Iterations)
=apaGraph.Layout.ForceDirected.AllParams(Edges, IsWeighted, SpringLength, TimeStep, RepulsionForce, AttractionConstant, Damping, Iterations)Result
Force-directed layout of an edge list with all parameters exposed. Returns a layout matrix with the node index in the first column and the X/Y coordinates in the next two columns.
Syntax
Edges: n x 3 edge list, the first two columns containing the node indices, the third column the distance between the two nodes (smaller = closer, e.g. sqrt(2(1-ρ)) for correlations ρ)
IsWeighted: TRUE to use the third column as edge distances, so that more similar nodes are placed closer together; FALSE to use unit distances
SpringLength: rest length of the springs. Default value: 0.5
TimeStep: time step of the simulation. Default value: 1
RepulsionForce: strength of the repulsive force between nodes. Default value: 1
AttractionConstant: spring constant of the attractive force along edges. Default value: 0.05
Damping: damping factor applied to the node velocities. Default value: 0.7
Iterations: number of iterations. Default value: 2000
Algorithm
The nodes are treated as charged particles repelling each other, the edges as springs attracting connected nodes.
In weighted mode, the distances are divided by their median and clipped to [0.05, 20]. Each edge is a spring with rest length SpringLength x distance and stiffness AttractionConstant / distance², capped at 0.5 / degree of the larger-degree end node for numerical stability; shorter distances thus give stiffer springs. Repulsion acts only between unconnected nodes, so that complete graphs reproduce the distances and sparse graphs such as trees can unfold without tangling. Duplicate edges keep the shortest distance.
Remarks
apaGraph.Layout.ForceDirected uses the default values of all parameters.
Pressing Esc aborts the calculation; the function then returns "Calculation aborted by user."
