cdlib.algorithms.lfm

cdlib.algorithms.lfm(g_original: object, alpha: float, weight: str = 'weight') NodeClustering

LFM is based on the local optimization of a fitness function. It finds both overlapping communities and the hierarchical structure.

Supported Graph Types

Undirected

Directed

Weighted

Yes

No

Yes

Parameters:
  • g_original – a networkx/igraph object

  • alpha – parameter to controll the size of the communities: Large values of alpha yield very small communities, small values instead deliver large modules. If alpha is small enough, all nodes end up in the same cluster, the network itself. In most cases, for alpha < 0.5 there is only one community, for alpha > 2 one recovers the smallest communities. A natural choise is alpha =1.

  • weight – name of the edge attribute containing the weights, default “weight”

Returns:

NodeClustering object

Example:

>>> from cdlib import algorithms
>>> import networkx as nx
>>> G = nx.karate_club_graph()
>>> com = algorithms.lfm(G, alpha=0.8)
References:

Lancichinetti, Andrea, Santo Fortunato, and János Kertész. Detecting the overlapping and hierarchical community structure in complex networks New Journal of Physics 11.3 (2009): 033015. Lancichinetti, Andrea, and Santo Fortunato. Benchmarks for testing community detection algorithms on directed and weighted graphs with overlapping communities <https://arxiv.org/abs/0904.3940/>_ Physical Review E 80.1 (2009): 016118.