eva(g_original: object, labels: dict, weight: str = 'weight', resolution: float = 1.0, alpha: float = 0.5) → cdlib.classes.attr_node_clustering.AttrNodeClustering

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.

Supported Graph Types

Undirected Directed Weighted Temporal Node Attribute
Yes No No No Yes
  • 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)
  • weight – str, optional the key in graph to use as weight. Default to ‘weight’
  • resolution – double, optional Will change the size of the communities, default to 1.
  • alpha – float, assumed in [0,1], optional Will tune the importance of modularity and purity criteria, default to 0.5

AttrNodeClustering object

>>> 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)

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.