brainconn.modularity
.modularity_dir¶
-
modularity_dir
(A, gamma=1, kci=None)[source]¶ The optimal community structure is a subdivision of the network into nonoverlapping groups of nodes in a way that maximizes the number of within-group edges, and minimizes the number of between-group edges. The modularity is a statistic that quantifies the degree to which the network may be subdivided into such clearly delineated groups.
Parameters: - W (NxN
numpy.ndarray
) – directed weighted/binary connection matrix - gamma (float) – resolution parameter. default value=1. Values 0 <= gamma < 1 detect larger modules while gamma > 1 detects smaller modules.
- kci (Nx1
numpy.ndarray
| None) – starting community structure. If specified, calculates the Q-metric on the community structure giving, without doing any optimzation. Otherwise, if not specified, uses a spectral modularity maximization algorithm.
Returns: - ci (Nx1
numpy.ndarray
) – optimized community structure - Q (float) – maximized modularity metric
Notes
This algorithm is deterministic. The matlab function bearing this name incorrectly disclaims that the outcome depends on heuristics involving a random seed. The louvain method does depend on a random seed, but this function uses a deterministic modularity maximization algorithm.
- W (NxN