pub fn modularity<N, E, Ix>(
graph: &Graph<N, E, Ix>,
communities: &HashMap<N, usize>,
) -> f64
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 analyzecommunities
- Map from nodes to community IDs
§Returns
- The modularity score (typically between -1 and 1, higher is better)