You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for (w, index_vw) inneighbors_with_edge_indices(g, v)
134
+
!has_diagonal(g) || (v == w &&continue)
135
+
iszero(color[w]) &&continue
136
+
x_exists =false
137
+
for (x, index_wx) inneighbors_with_edge_indices(g, w)
138
+
!has_diagonal(g) || (w == x &&continue)
139
+
if x != v && color[x] == color[v] # vw, wx ∈ E
140
+
star_wx = star[index_wx]
141
+
hub[star_wx] = w # this may already be true
142
+
star[index_vw] = star_wx
143
+
x_exists =true
144
+
break
145
+
end
146
+
end
147
+
if!x_exists
148
+
(p, q, index_pq) = first_neighbor[color[w]]
149
+
if p == v && q != w # vw, vq ∈ E and color[w] = color[q]
150
+
star_vq = star[index_pq]
151
+
hub[star_vq] = v # this may already be true
152
+
star[index_vw] = star_vq
153
+
else# vw forms a new star
154
+
push!(hub, -max(v, w)) # star is trivial (composed only of two vertices) so we set the hub to a negative value, but it allows us to choose one of the two vertices
155
+
star[index_vw] =length(hub)
156
+
end
157
+
end
158
+
end
124
159
end
125
160
star_set =StarSet(star, hub)
126
161
if postprocessing
@@ -131,64 +166,6 @@ function star_coloring(
131
166
return color, star_set
132
167
end
133
168
134
-
function_treat!(
135
-
# modified
136
-
treated::AbstractVector{<:Integer},
137
-
forbidden_colors::AbstractVector{<:Integer},
138
-
# not modified
139
-
g::AdjacencyGraph,
140
-
v::Integer,
141
-
w::Integer,
142
-
color::AbstractVector{<:Integer},
143
-
)
144
-
for x inneighbors(g, w)
145
-
!has_diagonal(g) || (w == x &&continue)
146
-
iszero(color[x]) &&continue
147
-
forbidden_colors[color[x]] = v
148
-
end
149
-
treated[w] = v
150
-
returnnothing
151
-
end
152
-
153
-
function_update_stars!(
154
-
# modified
155
-
star::AbstractVector{<:Integer},
156
-
hub::AbstractVector{<:Integer},
157
-
# not modified
158
-
g::AdjacencyGraph,
159
-
v::Integer,
160
-
color::AbstractVector{<:Integer},
161
-
first_neighbor::AbstractVector{<:Tuple},
162
-
)
163
-
for (w, index_vw) inneighbors_with_edge_indices(g, v)
164
-
!has_diagonal(g) || (v == w &&continue)
165
-
iszero(color[w]) &&continue
166
-
x_exists =false
167
-
for (x, index_wx) inneighbors_with_edge_indices(g, w)
168
-
!has_diagonal(g) || (w == x &&continue)
169
-
if x != v && color[x] == color[v] # vw, wx ∈ E
170
-
star_wx = star[index_wx]
171
-
hub[star_wx] = w # this may already be true
172
-
star[index_vw] = star_wx
173
-
x_exists =true
174
-
break
175
-
end
176
-
end
177
-
if!x_exists
178
-
(p, q, index_pq) = first_neighbor[color[w]]
179
-
if p == v && q != w # vw, vq ∈ E and color[w] = color[q]
180
-
star_vq = star[index_pq]
181
-
hub[star_vq] = v # this may already be true
182
-
star[index_vw] = star_vq
183
-
else# vw forms a new star
184
-
push!(hub, -max(v, w)) # star is trivial (composed only of two vertices) so we set the hub to a negative value, but it allows us to choose one of the two vertices
185
-
star[index_vw] =length(hub)
186
-
end
187
-
end
188
-
end
189
-
returnnothing
190
-
end
191
-
192
169
"""
193
170
StarSet
194
171
@@ -254,16 +231,13 @@ function acyclic_coloring(
254
231
!has_diagonal(g) || (w == x &&continue)
255
232
iszero(color[x]) &&continue
256
233
if forbidden_colors[color[x]] != v
257
-
_prevent_cycle!(
258
-
v,
259
-
w,
260
-
x,
261
-
index_wx,
262
-
color,
263
-
first_visit_to_tree,
264
-
forbidden_colors,
265
-
forest,
266
-
)
234
+
root_wx =find_root!(forest, index_wx) # root of the 2-colored tree to which the edge wx belongs
235
+
(p, q) = first_visit_to_tree[root_wx]
236
+
if p != v # T is being visited from vertex v for the first time
237
+
first_visit_to_tree[root_wx] = (v, w)
238
+
elseif q != w # T is connected to vertex v via at least two edges
239
+
forbidden_colors[color[x]] = v
240
+
end
267
241
end
268
242
end
269
243
end
@@ -276,7 +250,15 @@ function acyclic_coloring(
276
250
for (w, index_vw) inneighbors_with_edge_indices(g, v) # grow two-colored stars around the vertex v
0 commit comments