@@ -15,8 +15,8 @@ function color_graph(g::LightGraphs.AbstractGraph, ::BacktrackingColor)
15
15
16
16
# F is the coloring of vertices, 0 means uncolored
17
17
# 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)
20
20
21
21
start = 1
22
22
@@ -28,14 +28,14 @@ function color_graph(g::LightGraphs.AbstractGraph, ::BacktrackingColor)
28
28
29
29
# colors[j] = number of colors in A[0]...A[j]
30
30
# assume colors[0] = 1
31
- colors = zeros (Int , v)
31
+ colors = zeros (Integer , v)
32
32
33
33
# set of free colors
34
- U = zeros (Int , 0 )
34
+ U = zeros (Integer , 0 )
35
35
push! (U, 1 )
36
36
37
37
# set of free colors of x
38
- freeColors = [Vector {Int } () for _ in 1 : v]
38
+ freeColors = [Vector {Integer } () for _ in 1 : v]
39
39
freeColors[x] = copy (U)
40
40
41
41
while (start >= 1 )
@@ -112,12 +112,12 @@ function sort_by_degree(g::LightGraphs.AbstractGraph)
112
112
end
113
113
114
114
"""
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 })
116
116
117
117
Returns an uncolored vertex from the partially
118
118
colored graph which has the highest degree
119
119
"""
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 } )
121
121
for v in A
122
122
if F[v] == 0
123
123
return v
@@ -127,12 +127,12 @@ end
127
127
128
128
129
129
"""
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},
134
134
g::LightGraphs.AbstractGraph,
135
- opt::Int )
135
+ opt::Integer )
136
136
137
137
Returns set of free colors of x which are less
138
138
than optimal color number (opt)
@@ -147,15 +147,15 @@ F: F[i] stores the color of vertex i
147
147
g: Graph to be colored
148
148
opt: Current optimal number of colors to be used in the coloring of graph g
149
149
"""
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} ,
154
154
g:: LightGraphs.AbstractGraph ,
155
- opt:: Int )
155
+ opt:: Integer )
156
156
index = - 1
157
157
158
- freecolors = zeros (Int , 0 )
158
+ freecolors = zeros (Integer , 0 )
159
159
160
160
for i in eachindex (A)
161
161
if A[i] == x
@@ -189,12 +189,12 @@ function free_colors(x::Int,
189
189
end
190
190
191
191
"""
192
- least_index(F::Array{Int,1 }, A::Array{Int,1 }, opt::Int )
192
+ least_index(F::AbstractVector{<:Integer }, A::AbstractVector{<:Integer }, opt::Integer )
193
193
194
194
Returns least index i such that color of vertex
195
195
A[i] is equal to `opt` (optimal color number)
196
196
"""
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 )
198
198
for i in eachindex (A)
199
199
if F[A[i]] == opt
200
200
return i
@@ -203,29 +203,29 @@ function least_index(F::Array{Int,1}, A::Array{Int,1}, opt::Int)
203
203
end
204
204
205
205
"""
206
- uncolor_all(F::Array{Int,1 }, A::Array{Int,1 }, start::Int )
206
+ uncolor_all(F::AbstractVector{<:Integer }, A::AbstractVector{<:Integer }, start::Integer )
207
207
208
208
Uncolors all vertices A[i] where i is
209
209
greater than or equal to start
210
210
"""
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 )
212
212
for i = start: length (A)
213
213
F[A[i]] = 0
214
214
end
215
215
end
216
216
217
217
"""
218
- remove_higher_colors(U::Array{Int,1 }, opt::Int )
218
+ remove_higher_colors(U::AbstractVector{<:Integer }, opt::Integer )
219
219
220
220
Remove all the colors which are greater than or
221
221
equal to the `opt` (optimal color number) from
222
222
the set of colors U
223
223
"""
224
- function remove_higher_colors (U:: Array{Int,1 } , opt:: Int )
224
+ function remove_higher_colors (U:: AbstractVector{<:Integer } , opt:: Integer )
225
225
if length (U) == 0
226
226
return U
227
227
end
228
- u = zeros (Int , 0 )
228
+ u = zeros (Integer , 0 )
229
229
for color in U
230
230
if color < opt
231
231
push! (u, color)
0 commit comments