triangle_participation_ratio(graph: <Mock id='139911972657872'>, 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.

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