Skip to content
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

Added clique_number, independence_number #155

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dstahlke
Copy link

These simple implementations use maximal_cliques as the computational engine. Perhaps there is a more efficient way, but it would be great to at least have these implemented.

@gdalle gdalle added the enhancement New feature or request label Jun 16, 2023
Copy link
Member

@gdalle gdalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, sorry for the late review

src/community/cliques.jl Show resolved Hide resolved
test/community/cliques.jl Outdated Show resolved Hide resolved
test/community/cliques.jl Outdated Show resolved Hide resolved
@dstahlke
Copy link
Author

dstahlke commented Feb 7, 2024

I've pushed an update that hopefully addresses these concerns. (I rebased to master - hopefully that doesn't make the diffs too messy.)

After making a proper unit test for independent sets, I found I had to convert AbstractGraph to SimpleGraph in order to call complement. Performance shouldn't be an issue since this data copy is negligible in comparison to the cost of the maximal_cliques call. But I don't know if there is some other reason this would be problematic.

@traitfn function maximum_independent_set(
    g::AG::(!IsDirected)
) where {T,AG<:AbstractGraph{T}}
    # Convert to SimpleGraph first because `complement` doesn't accept AbstractGraph.
    return maximum_clique(complement(SimpleGraph(g)))

Copy link

codecov bot commented Feb 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f6f8db6) 97.28% compared to head (470df1c) 97.23%.
Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #155      +/-   ##
==========================================
- Coverage   97.28%   97.23%   -0.06%     
==========================================
  Files         115      115              
  Lines        6789     6790       +1     
==========================================
- Hits         6605     6602       -3     
- Misses        184      188       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gdalle
Copy link
Member

gdalle commented Mar 5, 2024

I would add a warning to the docstring pointing to the conversion, but otherwise I'd say it's okay

@dstahlke dstahlke requested a review from gdalle July 22, 2024 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants