|
| 1 | +""" |
| 2 | + fractional_chromatic_number(g; optimizer) |
| 3 | +
|
| 4 | +Compute the fractional chromatic number of a graph. Gives the same result as |
| 5 | +`fractional_clique_number`, though one function may run faster than the other. |
| 6 | +Beware: this can run very slowly for graphs of any substantial size. |
| 7 | +
|
| 8 | +# Keyword arguments |
| 9 | +
|
| 10 | +- `optimizer`: JuMP-compatible solver (default is `HiGHS.Optimizer`) |
| 11 | +
|
| 12 | +# References |
| 13 | +
|
| 14 | +- https://mathworld.wolfram.com/FractionalChromaticNumber.html |
| 15 | +""" |
| 16 | +function fractional_chromatic_number( |
| 17 | + g::AbstractGraph{T}, optimizer=HiGHS.Optimizer |
| 18 | +) where {T<:Integer} |
| 19 | + if is_directed(g) |
| 20 | + throw(ArgumentError("The graph must not be directed")) |
| 21 | + end |
| 22 | + |
| 23 | + ss = maximal_cliques(complement(g)) |
| 24 | + M = hcat(indvec.(ss, nv(g))...) |
| 25 | + |
| 26 | + model = Model(optimizer) |
| 27 | + set_silent(model) |
| 28 | + @variable(model, x[1:length(ss)] >= 0) |
| 29 | + @constraint(model, M * x .>= 1) |
| 30 | + @objective(model, Min, sum(x)) |
| 31 | + optimize!(model) |
| 32 | + return objective_value(model) |
| 33 | +end |
| 34 | + |
| 35 | +""" |
| 36 | + fractional_clique_number(g; optimizer) |
| 37 | +
|
| 38 | +Compute the fractional clique number of a graph. Gives the same result as |
| 39 | +`fractional_chromatic_number`, though one function may run faster than the other. |
| 40 | +Beware: this can run very slowly for graphs of any substantial size. |
| 41 | +
|
| 42 | +# Keyword arguments |
| 43 | +
|
| 44 | +- `optimizer`: JuMP-compatible solver (default is `HiGHS.Optimizer`) |
| 45 | +
|
| 46 | +# References |
| 47 | +
|
| 48 | +- https://mathworld.wolfram.com/FractionalCliqueNumber.html |
| 49 | +""" |
| 50 | +function fractional_clique_number( |
| 51 | + g::AbstractGraph{T}, optimizer=HiGHS.Optimizer |
| 52 | +) where {T<:Integer} |
| 53 | + if is_directed(g) |
| 54 | + throw(ArgumentError("The graph must not be directed")) |
| 55 | + end |
| 56 | + |
| 57 | + model = Model(optimizer) |
| 58 | + set_silent(model) |
| 59 | + @variable(model, x[1:nv(g)] >= 0) |
| 60 | + for clique in maximal_cliques(complement(g)) |
| 61 | + @constraint(model, sum(x[clique]) <= 1) |
| 62 | + end |
| 63 | + @objective(model, Max, sum(x)) |
| 64 | + optimize!(model) |
| 65 | + return objective_value(model) |
| 66 | +end |
0 commit comments