Skip to content

Added clique_number, independence_number#155

Merged
Krastanov merged 4 commits into
JuliaGraphs:masterfrom
dstahlke:cliques
Feb 21, 2026
Merged

Added clique_number, independence_number#155
Krastanov merged 4 commits into
JuliaGraphs:masterfrom
dstahlke:cliques

Conversation

@dstahlke

Copy link
Copy Markdown
Contributor

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

@gdalle gdalle left a comment

Copy link
Copy Markdown
Member

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

Comment thread src/community/cliques.jl
Comment thread test/community/cliques.jl Outdated
Comment thread test/community/cliques.jl Outdated
@dstahlke

dstahlke commented Feb 7, 2024

Copy link
Copy Markdown
Contributor Author

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)))

@codecov

codecov Bot commented Feb 21, 2024

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.22%. Comparing base (5eaa071) to head (29c01d3).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #155   +/-   ##
=======================================
  Coverage   97.22%   97.22%           
=======================================
  Files         122      122           
  Lines        7240     7250   +10     
=======================================
+ Hits         7039     7049   +10     
  Misses        201      201           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gdalle

gdalle commented Mar 5, 2024

Copy link
Copy Markdown
Member

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
@Krastanov
Krastanov merged commit 2cfcb1a into JuliaGraphs:master Feb 21, 2026
11 of 14 checks passed
@Krastanov

Copy link
Copy Markdown
Member

This looks good, and thankfully it has not bitrotten in the last two years. Thank you for the contribution!

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.

3 participants