-
-
Notifications
You must be signed in to change notification settings - Fork 392
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
Make is_graphical functions linear time #2605
base: master
Are you sure you want to change the base?
Make is_graphical functions linear time #2605
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2605 +/- ##
=======================================
Coverage 84.29% 84.30%
=======================================
Files 379 379
Lines 61949 61977 +28
Branches 12137 12147 +10
=======================================
+ Hits 52221 52250 +29
+ Misses 9728 9727 -1
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
ffd1a10
to
36bd61c
Compare
Thanks for taking on this issue! I marked this PR as draft for now. When it is ready to be merged, just click the "Ready for review" button. If you need help before then (for example to debug CI failures), let us know. |
36bd61c
to
d8bd722
Compare
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, this looks good to me!
Berger's relaxation is not mentioned any more in the documentation; I don't know the theorem well enough to judge whether this is correct or not so I leave it up to @szhorvat to decide.
I'm not familiar either but I assume it refers to this check: igraph/src/misc/graphicality.c Lines 849 to 853 in 19bb9ab
which I removed because in the original implementation it basically did an if check to see if it could skip another if check. However, your comment made me realise that it basically allows you to combine all indices |
Addresses #2546.
igraph_i_is_bigraphical_simple
to use counting sort to be linear time as discussed in the above issue.igraph_i_is_graphical_undirected_loopy_simple
which was using a comparison sort as well.Now
igraph_is_graphical()
should be linear in all cases.Benchmark results
To benchmark
igraph_i_is_bigraphical_simple
I used the benchmark for 'directed with single loops allowed' which is equivalent to it.igraph/src/misc/graphicality.c
Lines 571 to 577 in 223fd0e
bigraphical_simple before:
bigraphical_simple after:
graphical_undirected_loopy_simple before:
graphical_undirected_loopy_simple after: