Function modularity

Source
pub fn modularity<N, E, Ix>(
    graph: &Graph<N, E, Ix>,
    communities: &HashMap<N, usize>,
) -> f64
where N: Node, E: EdgeWeight + Into<f64> + Copy, Ix: IndexType,
Expand description

Computes the modularity of a given community partition

Modularity measures the quality of a partition by comparing the number of edges within communities to what would be expected in a random graph.

§Arguments

  • graph - The graph to analyze
  • communities - Map from nodes to community IDs

§Returns

  • The modularity score (typically between -1 and 1, higher is better)