cdlib.evaluation.cut_ratio¶
- cdlib.evaluation.cut_ratio(graph: Graph, community: object, summary: bool = True) object ¶
Fraction of existing edges (out of all possible edges) leaving the community.
\[f(S) = \frac{c_S}{n_S (n − n_S)}\]where \(c_S\) is the cut size (number of edges on the community boundary) and \(n_S\) is the number of community nodes
- Parameters:
graph – a networkx/igraph object
community – NodeClustering object
summary – boolean. If True it is returned an aggregated score for the partition is returned, otherwise individual-community ones. Default True.
- Returns:
If summary==True a FitnessResult object, otherwise a list of floats.
Example:
>>> from cdlib.algorithms import louvain >>> from cdlib import evaluation >>> g = nx.karate_club_graph() >>> communities = louvain(g) >>> mod = evaluation.cut_ratio(g,communities)
- References:
Fortunato, S.: Community detection in graphs. Physics reports 486(3-5), 75–174 (2010)