-
Notifications
You must be signed in to change notification settings - Fork 92
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
Greedy modularity optimization community detection algorithm #314
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #314 +/- ##
==========================================
- Coverage 97.26% 96.72% -0.54%
==========================================
Files 115 113 -2
Lines 6795 6201 -594
==========================================
- Hits 6609 5998 -611
- Misses 186 203 +17 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good first implem!
Try a weighted version and for every number that is not an integer, use the |
m = sum(w[src(e), dst(e)] for e in edges(g)) * 2 | ||
n_groups = maximum(c) | ||
a = zeros(modularity_type, n_groups) | ||
e = zeros(modularity_type, n_groups, n_groups) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we try a dict or sparse matrix here?
return rewrite_class_ids(cs[imax]) | ||
end | ||
|
||
function modularity_greedy_step!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test that this loop does not allocate
n = nv(g) | ||
dq_max::typeof(Q) = typemin(Q) | ||
to_merge::Tuple{Int,Int} = (0, 0) | ||
for edge in edges(g) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
investigate the case of self-loops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-loops indeed appear in modularity computation (in a correct way)
They do participate in modularity optimization step and they can also impact which merge is optimal. Yet we never merge a cluster with itself as we check that ends of an edge belong to different clusters at traversal stage.
add fast algo of Clauset and Newman with dense storage of potential modularity increase
Greedy modularity optimization algorithm as per paper of Newman