calc_modularity: Calculation of Modularity for a List of igraph Objects

View source: R/modularity.R

calc_modularityR Documentation

Calculation of Modularity for a List of igraph Objects

Description

This function calculates the modularity of a list of networks provided in the ig parameter. Modularity measures the strength of division of a network into modules (communities).

Usage

calc_modularity(ig, ncores = 0, cluster_function = cluster_spinglass)

Arguments

ig

A list of igraph objects for which modularity will be calculated.

ncores

Number of cores used for parallel computation. If set to 0, sequential processing is used.

cluster_function

The igraph clustering function to use, or a function that returns modularity. default cluster_spinglass.

weights

Edge weights. Can be a numeric vector, NULL, or NA:

  • If NULL, the function checks for a 'weight' edge attribute and uses it if present.

  • If NA, weights are ignored even if the graph has a 'weight' edge attribute.

Details

Note: cluster_spinglass() only works on networks with a single connected component.

Value

A data frame with a column Modularity containing the modularity values for each network.

Examples

## Not run: 
nullg <- generateERbasal(netData[[1]], 10)
calc_modularity(nullg, cluster_function = cluster_infomap)

## End(Not run)


lsaravia/EcoNetwork documentation built on April 5, 2025, 1:51 p.m.