ash_model.measures.attribute_analysis.attribute_consistency¶
- ash_model.measures.attribute_analysis.attribute_consistency(h, node=None)[source]¶
The consistency measures the extent to which a nodes’ attribute value remains constant/change across time. The higher the value, the more consistent in time are the node’s values for that attribute.
- Parameters:
- Returns:
A dict containing, for each node, for each attribute, the consistency value
- Return type:
Examples
Consistency for a specific node over time (avoid node=0 which is falsy in current implementation):
>>> 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) >>> attribute_consistency(h, node=1) {'color': np.float64(0.1187091007693073)}
Note: passing node=0 currently behaves as if no node was specified because 0 evaluates to False.