cdlib.algorithms.eva

eva(g_original, labels, weight='weight', resolution=1.0, randomize=False, alpha=0.5)

The Eva algorithm extends the Louvain approach in order to deal with the attributes of the nodes (aka Louvain Extended to Vertex Attributes). It optimizes - combining them linearly - two quality functions, a structural and a clustering one, namely Newman’s modularity and purity, estimated as the product of the frequencies of the most frequent labels carried by the nodes within the communities. A parameter alpha tunes the importance of the two functions: an high value of alpha favors the clustering criterion instead of the structural one.

param g_original:
 

a networkx/igraph object

param labels:

dictionary specifying for each node (key) a dict (value) specifying the name attribute (key) and its value (value)

param weight:

str, optional the key in graph to use as weight. Default to ‘weight’

param resolution:
 

double, optional Will change the size of the communities, default to 1.

param randomize:
 

boolean, optional Will randomize the node evaluation order and the community evaluation order to get different partitions at each call, default False

param alpha:

float, assumed in [0,1], optional Will tune the importance of modularity and purity criteria, default to 0.5

return:

AttrNodeClustering object

Example:
>>> from cdlib.algorithms import eva
>>> import networkx as nx
>>> import random
>>> l1 = ['A', 'B', 'C', 'D']
>>> l2 = ["E", "F", "G"]
>>> 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)}
>>> communities = eva(g_attr, labels, alpha=0.8)
References:
  1. Citraro, S., & Rossetti, G. (2019, December). Eva: Attribute-Aware Network Segmentation. In International Conference on Complex Networks and Their Applications (pp. 141-151). Springer, Cham.