.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/05_structure/plot_19_centrality_family.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_05_structure_plot_19_centrality_family.py: 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. .. GENERATED FROM PYTHON SOURCE LINES 13-35 .. code-block:: Python 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()) .. rst-class:: sphx-glr-script-out .. code-block:: none 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 .. GENERATED FROM PYTHON SOURCE LINES 36-45 .. code-block:: Python 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() .. image-sg:: /auto_examples/05_structure/images/sphx_glr_plot_19_centrality_family_001.png :alt: plot 19 centrality family :srcset: /auto_examples/05_structure/images/sphx_glr_plot_19_centrality_family_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.464 seconds) .. _sphx_glr_download_auto_examples_05_structure_plot_19_centrality_family.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/ComplexSystemsIntelligence/hatvis/main?urlpath=lab/tree/notebooks/auto_examples/05_structure/plot_19_centrality_family.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_19_centrality_family.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_19_centrality_family.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_19_centrality_family.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_