Learn R Programming

visNetwork (version 0.2.1)

visIgraphLayout: Use a igraph layout for compute coordinates & fast rendering

Description

Use a igraph layout for compute coordinates and fast rendering. This function affect x and y coordinates to nodes data.frame using a igraph layout, and then render network faster with no stabilization. We set some options as : visNodes(physics = FALSE) & visEdges(smooth = FALSE) & visPhysics(stabilization= FALSE), but you can overwrite them using arguments or by add another call after visIgraphLayout

Usage

visIgraphLayout(graph, layout = "layout_nicely", physics = FALSE,
  smooth = FALSE, type = "square")

Arguments

graph
: a visNetwork object
layout
: Character Name of igraph layout function to use. Default to "layout_nicely"
physics
: Boolean. Default to FALSE. Enabled physics on nodes ?
smooth
: Boolean. Default to FALSE. Use smooth edges ?
type
: Character Type of scale from igrah to vis.js. "square" (defaut) render in a square limit by height. "full" use width and height to scale in a rectangle.

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
nnodes <- 200
nnedges <- 400

nodes <- data.frame(id = 1:nnodes)
edges <- data.frame(from = sample(1:nnodes, nnedges, replace = T),
                   to = sample(1:nnodes, nnedges, replace = T))

# with defaut layout
visNetwork(nodes, edges) %>%
 visIgraphLayout() %>%
 visNodes(size = 10)

# use full space
visNetwork(nodes, edges) %>%
 visIgraphLayout(type = "full") %>%
 visNodes(size = 10)

# in circle ?
visNetwork(nodes, edges) %>%
 visIgraphLayout(layout = "layout_in_circle") %>%
 visNodes(size = 10) %>%
 visOptions(highlightNearest = T, nodesIdSelection = T)

# keep physics with smooth curves ?
visNetwork(nodes, edges) %>%
 visIgraphLayout(physics = TRUE, smooth = TRUE) %>%
 visNodes(size = 10)

Run the code above in your browser using DataLab