# cdlib.evaluation.erdos_renyi_modularity¶

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

Erdos-Renyi modularity is a variation of the Newman-Girvan one. It assumes that vertices in a network are connected randomly with a constant probability $$p$$.

$Q(S) = \frac{1}{m}\sum_{c \in S} (m_S − \frac{mn_S(n_S −1)}{n(n−1)})$

where $$m$$ is the number of graph edges, $$m_S$$ is the number of community edges, $$l_S$$ is the number of edges from nodes in S to nodes outside S.

Parameters: graph – a networkx/igraph object communities – NodeClustering object FitnessResult object

Example:

>>> from cdlib.algorithms import louvain
>>> from cdlib import evaluation
>>> g = nx.karate_club_graph()
>>> communities = louvain(g)
>>> mod = evaluation.erdos_renyi_modularity(g,communities)

1. Erdos, P., & Renyi, A. (1959). On random graphs I. Publ. Math. Debrecen, 6, 290-297.