Description Usage Arguments Value References Examples
View source: R/cluster_modularity.R
Find the communities of a graph by direct optimization of a modularity score. For simplicity, this function only accepts a symmetric network of \lbrace 0, 1 \rbrace binary edges.
1 | modularity(graph)
|
graph |
one of the followings; (1) an |
a named list containing
a length-N vector of class labels.
the computed modularity value.
modularity2004T4network
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## load the data
data(karate, package="T4network")
## community detection
karate.modular = T4network::modularity(karate$A)
karate.label = karate.modular$cluster
karate.true = karate$label
## wrap the graph as 'igraph' object
karate.igraph = igraph::graph_from_adjacency_matrix(karate$A, mode="undirected")
## visualize
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,2))
plot(karate.igraph, vertex.label=NA, vertex.color=karate.true, main="true label")
plot(karate.igraph, vertex.label=NA, vertex.color=karate.label, main="estimated label")
par(opar)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.