Learn R Programming

visNetwork (version 2.1.2)

visLayout: Network visualization layout options

Description

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

Usage

visLayout(
  graph,
  randomSeed = NULL,
  improvedLayout = NULL,
  clusterThreshold = NULL,
  hierarchical = NULL
)

Arguments

graph

: a visNetwork object

randomSeed

: Number. When NOT using the hierarchical layout, the nodes are randomly positioned initially. This means that the settled result is different every time. If you provide a random seed manually, the layout will be the same every time. Ideally you try with an undefined seed, reload until you are happy with the layout and use the getSeed() method to ascertain the seed.

improvedLayout

: Boolean. Default to true. When enabled, the network will use the Kamada Kawai algorithm for initial layout. For networks larger than 100 nodes, clustering will be performed automatically to reduce the amount of nodes. This can greatly improve the stabilization times. If the network is very interconnected (no or few leaf nodes), this may not work and it will revert back to the old method. Performance will be improved in the future.

clusterThreshold

: Number. Default to 150. Cluster threshold to which improvedLayout applies.

hierarchical

: Boolean. Default to false. When true, the layout engine positions the nodes in a hierarchical fashion using default settings. For customization you can use visHierarchicalLayout

References

See online documentation https://datastorm-open.github.io/visNetwork/

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

Run this code

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

# fix seed, so you retrieve same network each time...!
visNetwork(nodes, edges) %>%
 visLayout(randomSeed = 123) 

visNetwork(nodes, edges) %>%
 visLayout(randomSeed = 123)   
 
# hierarchical
visNetwork(nodes, edges) %>%
 visLayout(hierarchical = TRUE) 
 
visNetwork(nodes, edges) %>%
 visHierarchicalLayout(direction = "LR")

Run the code above in your browser using DataLab