A family of hypergraph centralities#

Degree, clique-expansion eigenvector (CEC), Z- and H-eigenvector (ZEC, HEC) centralities (Benson 2019), the nonlinear node–edge centralities of Tudisco and Higham (2021), PageRank and hyper-coreness (Mancastroppa et al. 2023) rank the vertices of a 3-uniform hypergraph. Their Spearman correlations show where they agree and where the higher-order definitions differ.

import matplotlib.pyplot as plt
import pandas as pd

import hatvis as hv

H = hv.models.chung_lu({f"v{i}": max(1, 30 // (i + 1)) for i in range(40)}, [3] * 70, random_state=0)
H = H.remove_isolated()
# [snippet:family]
C = pd.DataFrame({
    "degree": hv.degree_centrality(H),
    "CEC": hv.clique_eigenvector(H),
    "ZEC": hv.z_eigenvector(H),
    "HEC": hv.h_eigenvector(H),
    "linear NEC": hv.node_edge_eigenvector(H, "linear")[0],
    "max NEC": hv.node_edge_eigenvector(H, "max")[0],
    "PageRank": hv.pagerank(H),
    "hyper-coreness": hv.hypercoreness(H),
})
corr = C.corr(method="spearman")
# [/snippet:family]
print(corr.round(2).to_string())
                degree   CEC   ZEC   HEC  linear NEC  max NEC  PageRank  hyper-coreness
degree            1.00  0.94  0.77  0.92        0.92     0.90      0.99            0.97
CEC               0.94  1.00  0.91  0.99        0.99     0.96      0.90            0.94
ZEC               0.77  0.91  1.00  0.94        0.89     0.83      0.70            0.79
HEC               0.92  0.99  0.94  1.00        0.98     0.93      0.88            0.93
linear NEC        0.92  0.99  0.89  0.98        1.00     0.98      0.88            0.92
max NEC           0.90  0.96  0.83  0.93        0.98     1.00      0.88            0.90
PageRank          0.99  0.90  0.70  0.88        0.88     0.88      1.00            0.96
hyper-coreness    0.97  0.94  0.79  0.93        0.92     0.90      0.96            1.00
fig, ax = plt.subplots(figsize=(6.5, 5.5))
im = ax.imshow(corr, cmap="RdBu_r", vmin=-1, vmax=1)
ax.set_xticks(range(len(corr)), corr.columns, rotation=60, ha="right")
ax.set_yticks(range(len(corr)), corr.columns)
for i in range(len(corr)):
    for j in range(len(corr)):
        ax.text(j, i, f"{corr.iloc[i, j]:.2f}", ha="center", va="center", fontsize=7)
plt.colorbar(im, ax=ax, fraction=0.046, label="Spearman correlation")
plt.tight_layout()
plot 19 centrality family

Total running time of the script: (0 minutes 0.464 seconds)

Gallery generated by Sphinx-Gallery