ash_model.measures.star_profile_homogeneity¶
- ash_model.measures.star_profile_homogeneity(h, node_id, tid, method='aggregate')[source]¶
Returns the homogeneity of the star profile of a node, i.e., the relative frequency of the node’s attribute value for each attribute in the profiles of the nodes in the star of the given node. If method is ‘aggregate’, it is computed by first aggregating each hyperedge into a single profile (see hyperedge_aggregate_node_profile). Else if method is ‘collapse’, all the node’s neighbors are considered.
- Parameters:
- Returns:
A dictionary with the homogeneity of each attribute
- Return type:
Examples
Compute the star-profile homogeneity for a node (aggregate method) on 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) >>> tid = 0 >>> node0 = next(iter(h.nodes(start=tid, end=tid))) >>> star_profile_homogeneity(h, node0, tid, method='aggregate') {'color': 0.7741935483870968}