Color nodes by cluster.

sg_cluster(sg, colors = c("#B1E2A3", "#98D3A5", "#328983", "#1C5C70",
  "#24C96B"), directed = TRUE, algo = igraph::cluster_walktrap,
  quiet = !interactive(), ...)

sg_get_cluster(nodes, edges, colors = c("#B1E2A3", "#98D3A5", "#328983",
  "#1C5C70", "#24C96B"), directed = TRUE,
  algo = igraph::cluster_walktrap, quiet = !interactive(), ...)

Arguments

sg

An object of class sigmajsas intatiated by sigmajs.

colors

Palette to color the nodes.

directed

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

algo

An igraph clustering function.

quiet

Set to TRUE to print the number of clusters to the console.

...

Any parameter to pass to algo.

nodes, edges

Nodes and edges as prepared for sigmajs.

Value

sg_get_cluster returns nodes with color variable.

Functions

  • sg_cluster Color nodes by cluster.

  • sg_get_cluster helper to get graph's nodes color by cluster.

Examples

nodes <- sg_make_nodes() edges <- sg_make_edges(nodes, 15) sigmajs() %>% sg_nodes(nodes, id, size) %>% sg_edges(edges, id, source, target) %>% sg_layout() %>% sg_cluster()
#> Warning: Graph does not show in the RStudio Viewer; opening in browser
#> Found # 3 clusters
clustered <- sg_get_cluster(nodes, edges)
#> Found # 3 clusters