Layout your graph.

sg_layout(sg, directed = TRUE, layout = igraph::layout_nicely, ...)

sg_get_layout(nodes, edges, directed = TRUE,
  layout = igraph::layout_nicely, ...)

Arguments

sg

An object of class sigmajsas intatiated by sigmajs.

directed

Whether or not to create a directed graph, passed to graph_from_data_frame.

layout

An igraph layout function.

...

Any other parameter to pass to layout function.

nodes, edges

Nodes and edges as prepared for sigmajs.

Value

sg_get_layout returns nodes with x and y coordinates.

Functions

  • sg_layout layout your graph.

  • sg_get_layout helper to get graph's x and y positions.

Examples

nodes <- sg_make_nodes(250) # 250 nodes edges <- sg_make_edges(nodes, n = 500) sigmajs() %>% sg_nodes(nodes, id, size, color) %>% sg_edges(edges, id, source, target) %>% sg_layout()
#> Warning: Graph does not show in the RStudio Viewer; opening in browser
nodes_coords <- sg_get_layout(nodes, edges)