Learn R Programming

EGAnet (version 1.2.3)

louvain: Louvain Community Detection Algorithm

Description

Computes the Louvain community detection algorithm (Blondel et al., 2008)

Usage

louvain(A, method = c("modularity", "tefi"), resolution = 1, corr = NULL)

Value

Returns a list containing:

wc

A matrix of lower to higher order community membership detected in the network

modularity

A vector of modularity values corresponding the rows of the wc matrix

Arguments

A

Matrix or data frame. A network adjacency matrix

method

Character. Whether modularity or tefi should be used to optimize communities. Defaults to "modularity"

resolution

Numeric. Resolution parameter for computing modularity. Defaults to 1. Values smaller than 1 favor larger communities; values larger than 1 favor smaller communities

corr

Matrix or data frame. Correlation matrix to be used when method = "tefi"

Author

Alexander P. Christensen <alexpaulchristensen@gmail.com> and Hudson Golino <hfg9s@virginia.edu>

Details

This version was adapted from the Matlab code available here: https://perso.uclouvain.be/vincent.blondel/research/louvain.html. The code was adjusted to mirror the results of cluster_louvain. The Louvain algorithm's results can vary depending on node ordering. In this version, nodes are not shuffled so that consistent results can be achieved with the same node ordering. Results from cluster_louvain will shuffle nodes within the function and therefore will sometimes produce similar results and sometimes produce slightly different results. This version is based all in R and therefore is slower than the version in igraph.

References

Blondel, V. D., Guillaume, J.-L., Lambiotte, R., & Lefebvre, E. (2008). Fast unfolding of communities in large networks. Journal of Statistical Mechanics: Theory and Experiment, 2008, P10008.

Examples

Run this code
# Load data
dep <- depression[,24:44]

# Estimate correlations
corr <- qgraph::cor_auto(dep)

# Estimate network
net <- EBICglasso.qgraph(corr, n = nrow(dep))

# Estimate communities using modularity
louvain(net, method = "modularity")

# Estimate communities using tefi
louvain(net, method = "tefi", corr = corr)

Run the code above in your browser using DataLab