visPhysics {visNetwork} | R Documentation

## Network visualization Physics options

### Description

Network visualization Physics options. For full documentation, have a look at visDocumentation.

### Usage

    visPhysics(graph, solver = NULL, maxVelocity = NULL, minVelocity = NULL,
      timestep = NULL, barnesHut = NULL, forceAtlas2Based = NULL,
      repulsion = NULL, hierarchicalRepulsion = NULL, stabilization = NULL,
      adaptiveTimestep = NULL, enabled = NULL)

### Arguments

`graph` | : a visNetwork object
`solver` | : String. Default to 'barnesHut'. You can select your own solver. Possible options: 'barnesHut', 'repulsion', 'hierarchicalRepulsion', 'forceAtlas2Based'. When setting the hierarchical layout, the hierarchical repulsion solver is automaticaly selected, regardless of what you fill in here.
`maxVelocity` | : Number. Default to 50. The physics module limits the maximum velocity of the nodes to increase the time to stabilization. This is the maximium value.
`minVelocity` | : Number. Default to 0.1. Once the minimum velocity is reached for all nodes, we assume the network has been stabilized and the simulation stops.
`timestep` | : Number. Default to 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.

`barnesHut,`

named list of options

- "gravitationalConstant" : Number. Default to -2000. Gravity attracts. We like repulsion. So the value is negative. If you want the repulsion to be stronger, decrease the value (so -10000, -50000).

- "centralGravity" : Number. Default to 0.3. There is a central gravity attractor to pull the entire network back to the center.

- "springLength" : Number. Default to 95. The edges are modelled as springs. This springLength here is the the rest length of the spring.

- "springConstant" : Number. Default to 0.04. This is how 'sturdy' the springs are. Higher values mean stronger springs.

- "damping" : Number. Default to 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.

- "avoidOverlap" : Number. Default to 0. Accepted range: [0 .. 1]. When larger than 0, the size of the node is taken into account. The distance will be calculated from the radius of the encompassing circle of the node for both the gravity model. Value 1 is maximum overlap avoidance.

`forceAtlas2Based,`

named list of options

- "gravitationalConstant" : Number. Default to -50. Gravity attracts. We like repulsion. So the value is negative. If you want the repulsion to be stronger, decrease the value (so -10000, -50000).

- "centralGravity" : Number. Default to 0.01. There is a central gravity attractor to pull the entire network back to the center.

- "springLength" : Number. Default to 100. The edges are modelled as springs. This springLength here is the the rest length of the spring.

- "springConstant" : Number. Default to 0.08. This is how 'sturdy' the springs are. Higher values mean stronger springs.

- "damping" : Number. Default to 0.4. 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.

- "avoidOverlap" : Number. Default to 0. Accepted range: [0 .. 1]. When larger than 0, the size of the node is taken into account. The distance will be calculated from the radius of the encompassing circle of the node for both the gravity model. Value 1 is maximum overlap avoidance.

`repulsion,`

named list of options

- "nodeDistance" : Number. Default to 100. This is the range of influence for the repulsion.

- "centralGravity" : Number. Default to 0.2. There is a central gravity attractor to pull the entire network back to the center.

- "springLength" : Number. Default to 200. The edges are modelled as springs. This springLength here is the the rest length of the spring.

- "springConstant" : Number. Default to 0.05. This is how 'sturdy' the springs are. Higher values mean stronger springs.

- "damping" : Number. Default to 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,`

named list of options

- "nodeDistance" : Number. Default to 120. This is the range of influence for the repulsion.

- "centralGravity" : Number. Default to 0.0. There is a central gravity attractor to pull the entire network back to the center.

- "springLength" : Number. Default to 100. The edges are modelled as springs. This springLength here is the the rest length of the spring.

- "springConstant" : Number. Default to 0.01. This is how 'sturdy' the springs are. Higher values mean stronger springs.

- "damping" : Number. Default to 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.

`stabilization,`

Just a boolean, or a named list of options

- "enabled" : Boolean. Default to 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.

- "iterations" : Number. Default to 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.

- "updateInterval" : Number. Default to 50. 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.

- "onlyDynamicEdges" : Boolean. Default to 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.

- "fit" : Boolean. Default to true. Toggle whether or not you want the view to zoom to fit all nodes when the stabilization is finished.

`adaptiveTimestep` | : Boolean. Default to true. If this is enabled, the timestep will intelligently be adapted (only during the stabilization stage if stabilization is enabled!) to greatly decrease stabilization times. The timestep configured above is taken as the minimum timestep. This can be further improved by using the improvedLayout algorithm.
`enabled` | : Boolean. Default to true. Toggle the physics system on or off. This property is optional. If you define any of the options below and enabled is undefined, this will be set to true.

### See Also

visNodes for nodes options, visEdges for edges options, visGroups for groups options, visLegend for adding legend, visOptions for custom option, visLayout & visHierarchicalLayout for layout, visPhysics for control physics, visInteraction for interaction, visNetworkProxy & visFocus & visFit for animation within shiny, visDocumentation, visEvents, visConfigure ...

### Examples

    nodes <- data.frame(id = 1:10)
    edges <- data.frame(from = round(runif(8)*10), to = round(runif(8)*10))

    visNetwork(nodes, edges) %>%
     visPhysics(solver = "repulsion")

    visNetwork(nodes, edges) %>%
     visPhysics(solver = "forceAtlas2Based", forceAtlas2Based = list(gravitationalConstant = -10))

    visNetwork(nodes, edges) %>%
     visPhysics(stabilization = FALSE)

[Package visNetwork version 1.0.1 Index]