ash_model.measures.average_group_degree¶
- ash_model.measures.average_group_degree(h, tid, hyperedge_size=None)[source]¶
Computes the average degree of each group (nodes having the same label in the attribute)
- Parameters:
- Returns:
A dictionary with attribute names as keys and a dictionary of average degrees for each attribute value
- Return type:
Examples
Average degree by color at tid=0 with the dataset above:
>>> import numpy as np, networkx as nx >>> from ash_model.utils.networkx import from_networkx_maximal_cliques_list >>> Gs = [nx.barabasi_albert_graph(100, 3, seed=i) for i in range(10)] >>> rng = np.random.default_rng(42) >>> for G in Gs: ... for n in G.nodes(): ... G.nodes[n]['color'] = 'red' if rng.integers(0, 2) == 0 else 'blue' >>> h = from_networkx_maximal_cliques_list(Gs) >>> average_group_degree(h, tid=0) {'color': {'red': 4.854166666666667, 'blue': 5.0}}