Skip to content

Commit e999c65

Browse files
committed
[critical] Split row and column unused colors...
1 parent 167f98a commit e999c65

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/postprocessing.jl

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,32 @@ function postprocess!(
4949
)
5050
end
5151

52-
if bicoloring
53-
# Identify colors that are used in either the row or column partition
54-
# color_used = row_color_used .| column_color_used
55-
color_used .|= row_color_used
56-
end
52+
# if at least one of the colors is not used, modify the color assignments of vertices
53+
has_neutral_color = bicoloring ? any(!, row_color_used) || any(!, column_color_used) : any(!, color_used)
54+
55+
if has_neutral_color
56+
# size of the original matrix on which we want to perform coloring or bicoloring
57+
(m, n) = g.original_size
5758

58-
# if at least one of the colors is useless, modify the color assignments of vertices
59-
if any(!, color_used)
60-
num_colors_useless = 0
59+
# count the number of unused colors
60+
num_unused_colors = 0
6161

62-
# determine what are the useless colors and compute the offsets
62+
# count how many color indices are skipped before each color,
63+
# in order to compact the color indexing after removing unused colors
6364
for ci in 1:nb_colors
64-
if color_used[ci]
65-
offsets[ci] = num_colors_useless
65+
ci_required = bicoloring ? row_color_used[ci] || column_color_used[ci] : color_used[ci]
66+
if ci_required
67+
offsets[ci] = num_unused_colors
6668
else
67-
num_colors_useless += 1
69+
num_unused_colors += 1
6870
end
6971
end
7072

71-
# assign the neutral color to every vertex with a useless color and remap the colors
73+
# replace unused colors by the neutral color and compact the remaining color indices
7274
for i in eachindex(color)
7375
ci = color[i]
74-
if !color_used[ci]
76+
ci_used = (i n) ? column_color_used[ci] : row_color_used[ci]
77+
if !ci_used
7578
# assign the neutral color
7679
color[i] = 0
7780
else

0 commit comments

Comments
 (0)