Skip to content

Commit

Permalink
optimize hyperdegree
Browse files Browse the repository at this point in the history
  • Loading branch information
luowangzi7 committed May 13, 2024
1 parent 74e41aa commit 97f6bff
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions easygraph/functions/hypergraph/centrality/hyperdegree.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,25 @@ def hypergraph_degree_centrality(G):
Returns
----------
degree centrality of each node in G : dict
hyperdegree of each node in G : dict
"""
res = {}
node_list = G.v
# Get hyperedge list
edge_list = G.e[0]
for node in node_list:
res[node] = 0

res = {node: 0 for node in node_list}

for e in edge_list:
for n in e:
res[n] += 1
res.update({node: res[node] + 1 for node in e})
# res = {}
# node_list = G.v
# # Get hyperedge list
# edge_list = G.e[0]
# for node in node_list:
# res[node] = 0

# for e in edge_list:
# for n in e:
# res[n] += 1

return res

0 comments on commit 97f6bff

Please sign in to comment.