avg_embeddedness(graph: <Mock id='139911972634960'>, communities: object, **kwargs) → object

Average embeddedness of nodes within the community.

The embeddedness of a node n w.r.t. a community C is the ratio of its degree within the community and its overall degree.

\[emb(n,C) = \frac{k_n^C}{k_n}\]

The average embeddedness of a community C is:

\[avg_embd(c) = \frac{1}{|C|} \sum_{i \in C} \frac{k_n^C}{k_n}\]
  • graph – a networkx/igraph object
  • communities – 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)
>>> ave = evaluation.avg_embeddedness(g,communities)