cut_ratio(graph: <Mock id='139911972696464'>, 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

  • 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.

If summary==True a FitnessResult object, otherwise a list of floats.


>>> from cdlib.algorithms import louvain
>>> from cdlib import evaluation
>>> g = nx.karate_club_graph()
>>> communities = louvain(g)
>>> mod = evaluation.cut_ratio(g,communities)
  1. Fortunato, S.: Community detection in graphs. Physics reports 486(3-5), 75–174 (2010)