-
Notifications
You must be signed in to change notification settings - Fork 25
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 implementation of maximum cardinality search. #168
Conversation
Thank you for the PR! Looks very good, there is some conflict in the compat requirements of our packages, not sure what exactly conflicts. Cc @marcel3243 |
One could check whether this actually improves the performance of the Zigzag sampler. Maybe its not the bottleneck. On another note: since coding this I noted that it's possible to implement MCS without linked lists. Just use a Vector for each of the sets and store the set that each vertex is currently is in (like is probably already done with something like To move vertices to a new set, just insert them in the new set (and don't delete from the old one). To retrieve the vertex with maximum cardinality, just pop vertices Has same number of insertions/deletions as the linked list implementation. Memory consumption is limited by graph size. If I would reimplement MCS, I would probably take that route. |
Since the sets are disjoint, you can store the whole collection using three vectors of length |V|. This reduces allocations, which improves performance. |
Huh! Didn't know about this, cool idea :) |
I suspect that the problem is that I am only supporting Julia 1.10+, and you are testing with Julia 1.6. I will see if I can release an update that supports earlier versions of Julia. |
I benchmarked the old version BenchmarkTools.Trial: 3 samples with 1 evaluation per sample.
Range (min … max): 1.736 s … 1.963 s ┊ GC (min … max): 15.96% … 24.19%
Time (median): 1.861 s ┊ GC (median): 20.60%
Time (mean ± σ): 1.853 s ± 113.775 ms ┊ GC (mean ± σ): 20.42% ± 4.13%
█ █ █
█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█ ▁
1.74 s Histogram: frequency by time 1.96 s <
Memory estimate: 2.99 GiB, allocs estimate: 60403438. new version BenchmarkTools.Trial: 4 samples with 1 evaluation per sample.
Range (min … max): 1.522 s … 1.669 s ┊ GC (min … max): 25.69% … 30.39%
Time (median): 1.589 s ┊ GC (median): 27.95%
Time (mean ± σ): 1.592 s ± 80.245 ms ┊ GC (mean ± σ): 27.34% ± 3.69%
█ ▁ ▁
█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█▁▁▁▁▁█ ▁
1.52 s Histogram: frequency by time 1.67 s <
Memory estimate: 3.06 GiB, allocs estimate: 60820094. It's hard to say, but the run-time seems to have decreased. |
I can push an update that supports Julia 1.8 and 1.9. For 1.6 and 1.7, I would have to loosen some of the compatibility requirements in TreeWidthSolver. |
I am happy to drop < 1.8. |
Tests are passing (locally) on Julia versions
|
CI failed because it's on Julia 1.7. |
Let's see... |
Great, now CI is updated too. Is this ready to merge? |
Well well well! |
Yes, it's ready! |
I have a library CliqueTrees.jl with a faster implementation of the maximum cardinality algorithm. Here are some benchmarks.
current version
new version
You can take a look at the implementation here.