Skip to content

Commit 7149c41

Browse files
authored
Improve remap_colors (#173)
* Improve remap_colors * Update results.jl * Remove utils.jl
1 parent 4f26a6a commit 7149c41

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/result.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,9 @@ For all vertex indices `i` we have:
467467
remapped_color[i] = color_to_ind[color[i]]
468468
"""
469469
function remap_colors(color::Vector{Int})
470-
color_to_ind = Dict(c => i for (i, c) in enumerate(sort(unique(color[color .> 0]))))
471-
color_to_ind[0] = 0
470+
sorted_colors = sort!(unique(color))
471+
offset = sorted_colors[1] == 0 ? 1 : 0
472+
color_to_ind = Dict(c => i - offset for (i, c) in enumerate(sorted_colors))
472473
remapped_colors = [color_to_ind[c] for c in color]
473474
return remapped_colors, color_to_ind
474475
end

0 commit comments

Comments
 (0)