Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Commit d0af867

Browse files
committed
general fixes
1 parent 9b7cf7f commit d0af867

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

src/coloring/backtracking_coloring.jl

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ function color_graph(g::LightGraphs.AbstractGraph, ::BacktrackingColor)
1515

1616
#F is the coloring of vertices, 0 means uncolored
1717
#Fopt is the optimal coloring of the graph
18-
F = zeros(Int, v)
19-
Fopt= zeros(Int, v)
18+
F = zeros(Integer, v)
19+
Fopt= zeros(Integer, v)
2020

2121
start = 1
2222

@@ -28,14 +28,14 @@ function color_graph(g::LightGraphs.AbstractGraph, ::BacktrackingColor)
2828

2929
#colors[j] = number of colors in A[0]...A[j]
3030
#assume colors[0] = 1
31-
colors = zeros(Int, v)
31+
colors = zeros(Integer, v)
3232

3333
#set of free colors
34-
U = zeros(Int, 0)
34+
U = zeros(Integer, 0)
3535
push!(U, 1)
3636

3737
#set of free colors of x
38-
freeColors = [Vector{Int}() for _ in 1:v]
38+
freeColors = [Vector{Integer}() for _ in 1:v]
3939
freeColors[x] = copy(U)
4040

4141
while (start >= 1)
@@ -112,12 +112,12 @@ function sort_by_degree(g::LightGraphs.AbstractGraph)
112112
end
113113

114114
"""
115-
uncolored_vertex_of_maximal_degree(A::Array{Int,1},F::Array{Int,1})
115+
uncolored_vertex_of_maximal_degree(A::AbstractVector{<:Integer},F::AbstractVector{<:Integer})
116116
117117
Returns an uncolored vertex from the partially
118118
colored graph which has the highest degree
119119
"""
120-
function uncolored_vertex_of_maximal_degree(A::Array{Int,1},F::Array{Int,1})
120+
function uncolored_vertex_of_maximal_degree(A::AbstractVector{<:Integer},F::AbstractVector{<:Integer})
121121
for v in A
122122
if F[v] == 0
123123
return v
@@ -127,12 +127,12 @@ end
127127

128128

129129
"""
130-
free_colors(x::Int,
131-
A::Array{Int,1},
132-
colors::Array{Int,1},
133-
F::Array{Int64,1},
130+
free_colors(x::Integer,
131+
A::AbstractVector{<:Integer},
132+
colors::AbstractVector{<:Integer},
133+
F::Array{Integer64,1},
134134
g::LightGraphs.AbstractGraph,
135-
opt::Int)
135+
opt::Integer)
136136
137137
Returns set of free colors of x which are less
138138
than optimal color number (opt)
@@ -147,15 +147,15 @@ F: F[i] stores the color of vertex i
147147
g: Graph to be colored
148148
opt: Current optimal number of colors to be used in the coloring of graph g
149149
"""
150-
function free_colors(x::Int,
151-
A::Array{Int,1},
152-
colors::Array{Int,1},
153-
F::Array{Int64,1},
150+
function free_colors(x::Integer,
151+
A::AbstractVector{<:Integer},
152+
colors::AbstractVector{<:Integer},
153+
F::Array{Integer64,1},
154154
g::LightGraphs.AbstractGraph,
155-
opt::Int)
155+
opt::Integer)
156156
index = -1
157157

158-
freecolors = zeros(Int, 0)
158+
freecolors = zeros(Integer, 0)
159159

160160
for i in eachindex(A)
161161
if A[i] == x
@@ -189,12 +189,12 @@ function free_colors(x::Int,
189189
end
190190

191191
"""
192-
least_index(F::Array{Int,1}, A::Array{Int,1}, opt::Int)
192+
least_index(F::AbstractVector{<:Integer}, A::AbstractVector{<:Integer}, opt::Integer)
193193
194194
Returns least index i such that color of vertex
195195
A[i] is equal to `opt` (optimal color number)
196196
"""
197-
function least_index(F::Array{Int,1}, A::Array{Int,1}, opt::Int)
197+
function least_index(F::AbstractVector{<:Integer}, A::AbstractVector{<:Integer}, opt::Integer)
198198
for i in eachindex(A)
199199
if F[A[i]] == opt
200200
return i
@@ -203,29 +203,29 @@ function least_index(F::Array{Int,1}, A::Array{Int,1}, opt::Int)
203203
end
204204

205205
"""
206-
uncolor_all(F::Array{Int,1}, A::Array{Int,1}, start::Int)
206+
uncolor_all(F::AbstractVector{<:Integer}, A::AbstractVector{<:Integer}, start::Integer)
207207
208208
Uncolors all vertices A[i] where i is
209209
greater than or equal to start
210210
"""
211-
function uncolor_all!(F::Array{Int,1}, A::Array{Int,1}, start::Int)
211+
function uncolor_all!(F::AbstractVector{<:Integer}, A::AbstractVector{<:Integer}, start::Integer)
212212
for i = start:length(A)
213213
F[A[i]] = 0
214214
end
215215
end
216216

217217
"""
218-
remove_higher_colors(U::Array{Int,1}, opt::Int)
218+
remove_higher_colors(U::AbstractVector{<:Integer}, opt::Integer)
219219
220220
Remove all the colors which are greater than or
221221
equal to the `opt` (optimal color number) from
222222
the set of colors U
223223
"""
224-
function remove_higher_colors(U::Array{Int,1}, opt::Int)
224+
function remove_higher_colors(U::AbstractVector{<:Integer}, opt::Integer)
225225
if length(U) == 0
226226
return U
227227
end
228-
u = zeros(Int, 0)
228+
u = zeros(Integer, 0)
229229
for color in U
230230
if color < opt
231231
push!(u, color)

0 commit comments

Comments
 (0)