Network - physics

Handles the HTML part of the canvas.

Options

This is a list of all the methods in the public API. They are collected here from all individual modules.

nametypedefaultdescription
barnesHut Object Object BarnesHut is a quadtree based gravity model. This is the fastest, default and recommended solver for non-hierarchical layouts.
repulsion Object Object The repulsion model assumes nodes have a simplified repulsion field around them. It's force linearly decreases from 1 (at 0.5*nodeDistance and smaller) to 0 (at 2*nodeDistance).
repulsion.nodeDistance Number 100 This is the range of influence for the repulsion.
repulsion.centralGravity Number 0.2 There is a central gravity attractor to pull the entire network back to the center.
repulsion.springLength Number 200 The edges are modelled as springs. This springLength here is the the rest length of the spring.
repulsion.springConstant Number 0.05 This is how 'sturdy' the springs are. Higher values mean stronger springs.
repulsion.damping Number 0.09 Accepted range: [0 .. 1]. The damping factor is how much of the velocity from the previous physics simulation iteration carries over to the next iteration.
hierarchicalRepulsion Object Object This model is based on the repulsion solver but the levels are taken into account and the forces are normalized.
hierarchicalRepulsion.nodeDistance Number 120 This is the range of influence for the repulsion.
hierarchicalRepulsion.centralGravity Number 0.0' There is a central gravity attractor to pull the entire network back to the center.
hierarchicalRepulsion.springLength Number 100 The edges are modelled as springs. This springLength here is the the rest length of the spring.
hierarchicalRepulsion.springConstant Number 0.01 This is how 'sturdy' the springs are. Higher values mean stronger springs.
hierarchicalRepulsion.damping Number 0.09 Accepted range: [0 .. 1]. The damping factor is how much of the velocity from the previous physics simulation iteration carries over to the next iteration.
maxVelocity Number 50 The physics module limits the maximum velocity of the nodes to increase the time to stabilization. This is the maximium value.
minVelocity Number 0.1 Once the minimum velocity is reached for all nodes, we assume the network has been stabilized and the simulation stops.
solver String 'barnesHut'You can select your own solver. Possible options: 'barnesHut','repulsion','hierarchicalRepulsion'. When setting the hierarchical layout, the hierarchical repulsion solver is automaticaly selected, regardless of what you fill in here.
stabilization Object | BooleanObject When true, the network is stabilized on load using default settings. If false, stabilization is disabled. To further customize this, you can supply an object.
stabilization.enabled Boolean true Toggle the stabilization. This is an optional property. If undefined, it is automatically set to true when any of the properties of this object are defined.
stabilization.iterations Number 1000 The physics module tries to stabilize the network on load up til a maximum number of iterations defined here. If the network stabilized with less, you are finished before the maximum number.
stabilization.updateInterval Number 100 When stabilizing, the DOM can freeze. You can chop the stabilization up into pieces to show a loading bar for instance. The interval determines after how many iterations the stabilizationProgress event is triggered.
stabilization.onlyDynamicEdges Boolean false If you have predefined the position of all nodes and only want to stabilize the dynamic smooth edges, set this to true. It freezes all nodes except the invisible dynamic smooth curve support nodes. If you want the visible nodes to move and stabilize, do not use this.
stabilization.zoomExtent Boolean true Toggle whether or not you want the view to zoom to fit all nodes when the stabilization is finished.
timestep Number 0.5 The physics simulation is discrete. This means we take a step in time, calculate the forces, move the nodes and take another step. If you increase this number the steps will be too large and the network can get unstable. If you see a lot of jittery movement in the network, you may want to reduce this value a little.

Methods

This is a list of all the methods in the public API. Options can be set directly to the module or you can use the setOptions method of the network itself and use the module name as an object name.

.
namereturnsdescription
startSimulation() noneStart the physics simulation. This is normally done whenever needed and is only really useful if you stop the simulation yourself and wish to continue it afterwards.
stopSimulation() noneThis stops the physics simulation and triggers a stabilized event. It can be restarted by dragging a node, altering the dataset or calling startSimulation().
stabilize() noneYou can manually call stabilize at any time. All the stabilization options above are used.

Events

This is a list of all the events in the public API. They are collected here from all individual modules.

namepropertiesdescription
startStabilizingnoneFired when stabilization starts. This is also the case when you drag a node and the physics simulation restarts to stabilize again. Stabilization does not neccesarily imply 'without showing'.
stabilizationProgress
{
  iterations: Number // iterations so far,
  total: Number // total iterations in options
}
Fired when a multiple of the updateInterval number of iterations is reached. This only occurs in the 'hidden' stabilization.
stabilizationIterationsDonenoneFired when the 'hidden' stabilization finishes. This does not necessarily mean the network is stabilized; it could also mean that the amount of iterations defined in the options has been reached.
stabilized
{
  iterations: Number // iterations it took
}
Fired when the network has stabilized or when the stopSimulation() has been called. The amount of iterations it took could be used to tweak the maximum amount of iterations needed to stabilize the network.