@@ -79,6 +79,7 @@ If `postprocessing=true`, some colors might be replaced with `0` (the "neutral"
7979function star_coloring (g:: AdjacencyGraph , order:: AbstractOrder , postprocessing:: Bool )
8080 # Initialize data structures
8181 S = pattern (g)
82+ has_diag = has_diagonal (g)
8283 nv = nb_vertices (g)
8384 ne = nb_edges (g)
8485 color = zeros (Int, nv)
@@ -91,8 +92,9 @@ function star_coloring(g::AdjacencyGraph, order::AbstractOrder, postprocessing::
9192 vertices_in_order = vertices (g, order)
9293
9394 for v in vertices_in_order
94- for (iw, w) in enumerate (neighbors2 (g, v))
95- (v == w || iszero (color[w])) && continue
95+ for (iw, w) in enumerate (neighbors (g, v))
96+ ! has_diag || (v == w && continue )
97+ iszero (color[w]) && continue
9698 index_vw = edge_to_index[S. colptr[v] + iw - 1 ]
9799 forbidden_colors[color[w]] = v
98100 (p, q, _) = first_neighbor[color[w]]
@@ -105,8 +107,9 @@ function star_coloring(g::AdjacencyGraph, order::AbstractOrder, postprocessing::
105107 _treat! (treated, forbidden_colors, g, v, w, color)
106108 else
107109 first_neighbor[color[w]] = (v, w, index_vw)
108- for (ix, x) in enumerate (neighbors2 (g, w))
109- (w == x || x == v || iszero (color[x])) && continue
110+ for (ix, x) in enumerate (neighbors (g, w))
111+ ! has_diag || (w == x && continue )
112+ (x == v || iszero (color[x])) && continue
110113 index_wx = edge_to_index[S. colptr[w] + ix - 1 ]
111114 if x == hub[star[index_wx]] # potential Case 2 (which is always false for trivial stars with two vertices, since the associated hub is negative)
112115 forbidden_colors[color[x]] = v
@@ -140,7 +143,9 @@ function _treat!(
140143 w:: Integer ,
141144 color:: AbstractVector{<:Integer} ,
142145)
146+ has_diag = has_diagonal (g)
143147 for x in neighbors (g, w)
148+ ! has_diag || (w == x && continue )
144149 iszero (color[x]) && continue
145150 forbidden_colors[color[x]] = v
146151 end
@@ -160,12 +165,14 @@ function _update_stars!(
160165 edge_to_index:: AbstractVector{<:Integer} ,
161166)
162167 S = pattern (g)
163- for (iw, w) in enumerate (neighbors2 (g, v))
164- (v == w || iszero (color[w])) && continue
168+ has_diag = has_diagonal (g)
169+ for (iw, w) in enumerate (neighbors (g, v))
170+ ! has_diag || (v == w && continue )
171+ iszero (color[w]) && continue
165172 index_vw = edge_to_index[S. colptr[v] + iw - 1 ]
166173 x_exists = false
167- for (ix, x) in enumerate (neighbors2 (g, w))
168- (w == x) && continue
174+ for (ix, x) in enumerate (neighbors (g, w))
175+ ! has_diag || (w == x && continue )
169176 if x != v && color[x] == color[v] # vw, wx ∈ E
170177 index_wx = edge_to_index[S. colptr[w] + ix - 1 ]
171178 star_wx = star[index_wx]
@@ -232,6 +239,7 @@ If `postprocessing=true`, some colors might be replaced with `0` (the "neutral"
232239function acyclic_coloring (g:: AdjacencyGraph , order:: AbstractOrder , postprocessing:: Bool )
233240 # Initialize data structures
234241 S = pattern (g)
242+ has_diag = has_diagonal (g)
235243 nv = nb_vertices (g)
236244 ne = nb_edges (g)
237245 color = zeros (Int, nv)
@@ -244,13 +252,16 @@ function acyclic_coloring(g::AdjacencyGraph, order::AbstractOrder, postprocessin
244252
245253 for v in vertices_in_order
246254 for w in neighbors (g, v)
255+ ! has_diag || (v == w && continue )
247256 iszero (color[w]) && continue
248257 forbidden_colors[color[w]] = v
249258 end
250259 for w in neighbors (g, v)
260+ ! has_diag || (v == w && continue )
251261 iszero (color[w]) && continue
252- for (ix, x) in enumerate (neighbors2 (g, w))
253- (w == x || iszero (color[x])) && continue
262+ for (ix, x) in enumerate (neighbors (g, w))
263+ ! has_diag || (w == x && continue )
264+ iszero (color[x]) && continue
254265 if forbidden_colors[color[x]] != v
255266 index_wx = edge_to_index[S. colptr[w] + ix - 1 ]
256267 _prevent_cycle! (
@@ -272,15 +283,18 @@ function acyclic_coloring(g::AdjacencyGraph, order::AbstractOrder, postprocessin
272283 break
273284 end
274285 end
275- for (iw, w) in enumerate (neighbors2 (g, v)) # grow two-colored stars around the vertex v
276- (v == w || iszero (color[w])) && continue
286+ for (iw, w) in enumerate (neighbors (g, v)) # grow two-colored stars around the vertex v
287+ ! has_diag || (v == w && continue )
288+ iszero (color[w]) && continue
277289 index_vw = edge_to_index[S. colptr[v] + iw - 1 ]
278290 _grow_star! (v, w, index_vw, color, first_neighbor, forest)
279291 end
280- for (iw, w) in enumerate (neighbors2 (g, v))
281- (v == w || iszero (color[w])) && continue
282- for (ix, x) in enumerate (neighbors2 (g, w))
283- (w == x || x == v || iszero (color[x])) && continue
292+ for (iw, w) in enumerate (neighbors (g, v))
293+ ! has_diag || (v == w && continue )
294+ iszero (color[w]) && continue
295+ for (ix, x) in enumerate (neighbors (g, w))
296+ ! has_diag || (w == x && continue )
297+ (x == v || iszero (color[x])) && continue
284298 if color[x] == color[v]
285299 index_vw = edge_to_index[S. colptr[v] + iw - 1 ]
286300 index_wx = edge_to_index[S. colptr[w] + ix - 1 ]
0 commit comments