Skip to content

Commit 5aef3ab

Browse files
committed
Don't handle forced colors in acyclic
1 parent 678b26b commit 5aef3ab

1 file changed

Lines changed: 7 additions & 22 deletions

File tree

src/coloring.jl

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,7 @@ struct StarSet{T}
250250
end
251251

252252
"""
253-
acyclic_coloring(
254-
g::AdjacencyGraph, vertices_in_order::AbstractVector, postprocessing::Bool;
255-
forced_colors::Union{AbstractVector,Nothing}=nothing
256-
)
253+
acyclic_coloring(g::AdjacencyGraph, vertices_in_order::AbstractVector, postprocessing::Bool)
257254
258255
Compute an acyclic coloring of all vertices in the adjacency graph `g` and return a tuple `(color, tree_set)`, where
259256
@@ -266,8 +263,6 @@ The vertices are colored in a greedy fashion, following the order supplied.
266263
267264
If `postprocessing=true`, some colors might be replaced with `0` (the "neutral" color) as long as they are not needed during decompression.
268265
269-
The optional `forced_colors` keyword argument is used to enforce predefined vertex colors (e.g. coming from another optimization algorithm) but still run the acyclic coloring procedure to verify correctness and build auxiliary data structures, useful during decompression.
270-
271266
# See also
272267
273268
- [`AdjacencyGraph`](@ref)
@@ -278,10 +273,7 @@ The optional `forced_colors` keyword argument is used to enforce predefined vert
278273
> [_New Acyclic and Star Coloring Algorithms with Application to Computing Hessians_](https://epubs.siam.org/doi/abs/10.1137/050639879), Gebremedhin et al. (2007), Algorithm 3.1
279274
"""
280275
function acyclic_coloring(
281-
g::AdjacencyGraph{T},
282-
vertices_in_order::AbstractVector{<:Integer},
283-
postprocessing::Bool;
284-
forced_colors::Union{AbstractVector{<:Integer},Nothing}=nothing,
276+
g::AdjacencyGraph{T}, vertices_in_order::AbstractVector{<:Integer}, postprocessing::Bool
285277
) where {T<:Integer}
286278
# Initialize data structures
287279
nv = nb_vertices(g)
@@ -320,18 +312,11 @@ function acyclic_coloring(
320312
end
321313
end
322314
end
323-
if isnothing(forced_colors)
324-
for i in eachindex(forbidden_colors)
325-
if forbidden_colors[i] != v
326-
color[v] = i
327-
break
328-
end
329-
end
330-
else
331-
if forbidden_colors[forced_colors[v]] == v # TODO: handle forced_colors[v] == 0
332-
throw(InvalidColoringError())
333-
else
334-
color[v] = forced_colors[v]
315+
# TODO: handle forced colors
316+
for i in eachindex(forbidden_colors)
317+
if forbidden_colors[i] != v
318+
color[v] = i
319+
break
335320
end
336321
end
337322
for (w, index_vw) in neighbors_with_edge_indices(g, v) # grow two-colored stars around the vertex v

0 commit comments

Comments
 (0)