[docs]defvector_centrality(H):"""The vector centrality of nodes in the line graph of the hypergraph. Parameters ---------- H : eg.Hypergraph Returns ------- dict Centrality, where keys are node IDs and values are lists of centralities. References ---------- "Vector centrality in hypergraphs", K. Kovalenko, M. Romance, E. Vasilyeva, D. Aleja, R. Criado, D. Musatov, A.M. Raigorodskii, J. Flores, I. Samoylenko, K. Alfaro-Bittner, M. Perc, S. Boccaletti, https://doi.org/10.1016/j.chaos.2022.112397 """# If the hypergraph is empty, then return an empty dictionaryifH.num_v==0:returndict()LG=H.get_linegraph()ifnoteg.is_connected(LG):raiseEasyGraphError("This method is not defined for disconnected hypergraphs.")LGcent=eg.eigenvector_centrality(LG)vc={node:[]fornodeinrange(0,H.num_v)}edge_label_dict={tuple(edge):indexforindex,edgeinenumerate(H.e[0])}hyperedge_dims={tuple(edge):len(edge)foredgeinH.e[0]}D=max([len(e)foreinH.e[0]])forkinrange(2,D+1):c_i=np.zeros(H.num_v)foredge,_inlist(filter(lambdax:x[1]==k,hyperedge_dims.items())):fornodeinedge:try:c_i[node]+=LGcent[edge_label_dict[edge]]exceptIndexError:raiseException("Nodes must be written with the Pythonic indexing (0,1,2...)")c_i*=1/kfornodeinrange(H.num_v):vc[node].append(c_i[node])returnvc