-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to calculate the average path length? #511
Comments
Thanks for the question @YuhuYang. For a hypergraph You can then just collect the lengths and take the average like so: lens = []
for tup in spl:
lens += tup[1].values()
# remove lengths 0 for self-loops
lens = [i for i in lens if i!=0]
# replace inf by 0 for disconnected nodes
lens = [0 if i==np.inf else i for i in lens]
avg_shortest_path = np.sum(lens) / (N * (N-1)) # = np.mean(lens) You can find other global measures by exploring this page. You can find assortativity measures, clustering coefficient, or the density for example. |
Thank you very much! |
Note for self: not closing because we could put this a recipe or new function. |
Can you check what part is taking time? I expect it is the |
Yes, its is the |
Hi @YuhuYang! Computing the shortest past between two nodes is a computationally complex task, so it's normal for it to take some time. My suggestions to decrease the computational cost are:
I hope this helps! Happy coding! |
Thanks again! I'll try them! |
|
how to calculate global indicators of hypergraphs? Like the average path length, diameter
The text was updated successfully, but these errors were encountered: