cluster: Cluster

Description Usage Arguments Details Value Functions Examples

Description

Color nodes by cluster.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
sg_cluster(
  sg,
  colors = c("#B1E2A3", "#98D3A5", "#328983", "#1C5C70", "#24C96B"),
  directed = TRUE,
  algo = igraph::cluster_walktrap,
  quiet = !interactive(),
  save_igraph = TRUE,
  ...
)

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

Arguments

sg

An object of class sigmajs as instantiated 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.

save_igraph

Whether to save the igraph object used internally.

...

Any parameter to pass to algo.

nodes, edges

Nodes and edges as prepared for sigmajs.

Details

The package uses igraph internally for a lot of computations the save_igraph allows saving the object to speed up subsequent computations.

Value

sg_get_cluster returns nodes with color variable while sg_cluster returns an object of class htmlwidget which renders the visualisation on print.

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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()

clustered <- sg_get_cluster(nodes, edges)

JohnCoene/sigmajs documentation built on Feb. 1, 2021, 12:12 p.m.