Skip to main content

modularity

Function modularity 

Source
pub fn modularity(
    edges: &[(usize, usize, f64)],
    n_nodes: usize,
    communities: &[usize],
) -> f64
Expand description

Compute Newman-Girvan modularity Q for a partition of an edge-list graph.

Q = 1/(2m) · Σ_{i,j} [A_{ij} − k_i·k_j/(2m)] · δ(c_i, c_j)

§Arguments

  • edges – Weighted edge list (src, dst, weight).
  • n_nodes – Total number of nodes.
  • communities – Community assignment for each node.