cdlib.algorithms.ilouvain

ilouvain(g_original: object, labels: dict) → cdlib.classes.attr_node_clustering.AttrNodeClustering

The I-Louvain algorithm extends the Louvain approach in order to deal only with the scalar attributes of the nodes. It optimizes Newman’s modularity combined with an entropy measure.

Parameters:
  • g_original – a networkx/igraph object
  • labels – dictionary specifying for each node (key) a dict (value) specifying the name attribute (key) and its value (value)
Returns:

AttrNodeClustering object

Example:
>>> from cdlib.algorithms import ilouvain
>>> import networkx as nx
>>> import random
>>> l1 = [0.1, 0.4, 0.5]
>>> l2 = [34, 3, 112]
>>> g_attr = nx.barabasi_albert_graph(100, 5)
>>> labels=dict()
>>> for node in g_attr.nodes():
>>>    labels[node]={"l1":random.choice(l1), "l2":random.choice(l2)}
>>> id = dict()
>>> for n in g.nodes():
>>>     id[n] = n
>>> communities = ilouvain(g_attr, labels, id)
References:

Combe D., Largeron C., Géry M., Egyed-Zsigmond E. “I-Louvain: An Attributed Graph Clustering Method”. <https://link.springer.com/chapter/10.1007/978-3-319-24465-5_16> In: Fromont E., De Bie T., van Leeuwen M. (eds) Advances in Intelligent Data Analysis XIV. IDA (2015). Lecture Notes in Computer Science, vol 9385. Springer, Cham