-
Notifications
You must be signed in to change notification settings - Fork 95
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
Faster dorogovtsev mendes #371
Faster dorogovtsev mendes #371
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #371 +/- ##
=======================================
Coverage 97.28% 97.28%
=======================================
Files 118 118
Lines 6876 6876
=======================================
Hits 6689 6689
Misses 187 187 ☔ View full report in Codecov by Sentry. |
Failures on nightly are expected |
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.
Thanks for the fix, this is nearly good to go!
As suggested Co-authored-by: Guillaume Dalle <[email protected]>
Addresses #370.
This implementation has$O(N)$ runtime, while the previous implementation had $O(N^2)$ runtime.
The optimization comes from storing all edges added at each iteration in an indexed table, allowing to draw a random edge in$O(1)$ time, while the previous implementation had to go through (on average) half on the nodes in order to draw a random edge, which takes $O(N)$ time.
On my computer, this implementation uses approximately 16% more memory.
It runs faster than the previous one even on small graphs ($N = 100$ ).