ash_model.measures.s_second_order_centrality¶
- ash_model.measures.s_second_order_centrality(h, s, start=None, end=None, edges=True)[source]¶
Returns the second-order centrality of the nodes in the line graph of the hypergraph. If edges is True, the function computes the second-order centrality for hyperedges (the nodes of the line graph). If edges is False, it computes the second-order centrality for nodes by first converting the hypergraph to its dual.
- Parameters:
- Returns:
a dictionary mapping node IDs (or edge IDs if edges is True) to their second-order centrality values
- Return type:
Examples
>>> 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) >>> head3 = sorted(list(s_second_order_centrality(h, 1, start=0, end=0).items()))[:3] >>> head3 [('e1', 373.1451853808109), ('e10', 226.34942005127067), ('e100', 687.213714885934)]