cdlib.evaluation.triangle_participation_ratio

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

Fraction of community nodes that belong to a triad.

\[f(S) = \frac{ | \{ u: u \in S,\{(v,w):v, w \in S,(u,v) \in E,(u,w) \in E,(v,w) \in E \} \not = \emptyset \} |}{n_S}\]

where \(n_S\) is the set 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.triangle_participation_ratio(g,communities)
References:
  1. Yang, J., Leskovec, J.: Defining and evaluating network communities based on ground-truth. Knowledge and Information Systems 42(1), 181–213 (2015)