cdlib.algorithms.ilouvain

cdlib.algorithms.ilouvain(g_original: object, labels: dict) AttrNodeClustering

I-Louvain算法扩展了Louvain方法,以便仅处理节点的标量属性。 它优化了Newman的模块性,并结合了熵度量。

支持的图表类型

无向

有向

加权

时间

节点属性

是的

是的

Parameters:
  • g_original – 一个 networkx/igraph 对象

  • labels – 字典,为每个节点(键)指定一个字典(值),该字典指定名称属性(键)及其值(值)

Returns:

AttrNodeClustering 对象

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: 一种属性图聚类方法”。 <https://link.springer.com/chapter/10.1007/978-3-319-24465-5_16> 收录于:Fromont E., De Bie T., van Leeuwen M. (编辑) 智能数据分析进展 XIV. IDA (2015). 计算机科学讲义, 卷 9385. Springer, Cham