cdlib.evaluation.cut_ratio

cut_ratio(graph: <Mock id='140350750934288'>, community: object, summary: bool = True) → object

Fraction of existing edges (out of all possible edges) leaving the community.

..math:: f(S) = frac{c_S}{n_S (n − n_S)}

where \(c_S\) is the number of community nodes and, \(n_S\) is the number of edges on the community boundary

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:
  1. Fortunato, S.: Community detection in graphs. Physics reports 486(3-5), 75–174 (2010)