ash_model.measures.s_katz

ash_model.measures.s_katz(h, s, start=None, end=None, edges=True, alpha=0.1, beta=1.0, max_iter=1000, tol=1e-06, normalized=True)[source]

Returns the Katz centrality of the nodes in the line graph of the hypergraph. If edges is True, the function computes the Katz centrality for hyperedges ( the nodes of the line graph). If edges is False, it computes the Katz centrality for nodes by first converting the hypergraph to its dual.

Parameters:
  • h (ASH) – the ASH instance

  • s (int) – minimum hyperedge overlap size for paths

  • start (int | None) – start time of the interval

  • end (int | None) – end time of the interval

  • edges (bool) – if True, compute for hyperedges; if False, compute for nodes

  • normalized (bool) – if True, normalize the Katz centrality values

  • alpha (float) – attenuation factor for the Katz centrality

  • beta (float) – scaling factor for the Katz centrality

  • max_iter (int) – maximum number of iterations for the Katz centrality calculation

  • tol (float) – tolerance for the Katz centrality calculation

Returns:

a dictionary mapping node IDs (or edge IDs if edges is True) to their Katz centrality values

Return type:

dict

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_katz(h, 1, start=0, end=0).items()))[:3]
>>> [(k, float(v)) for k,v in head3]
[('e1', 0.015921892363685495), ('e10', -0.01107345978999999), ('e100', 0.03526804656510612)]