Graphs.jl
Graphs.jl copied to clipboard
Added clique_number, independence_number
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.
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 Report
All modified and coverable lines are covered by tests :white_check_mark:
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
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I would add a warning to the docstring pointing to the conversion, but otherwise I'd say it's okay