@@ -83,34 +83,13 @@ function star_coloring(g::AdjacencyGraph, order::AbstractOrder, postprocessing::
8383 ne = nb_edges (g)
8484 color = zeros (Int, nv)
8585 forbidden_colors = zeros (Int, nv)
86- edge_to_index = Vector {Int} (undef, nnz (S) )
86+ edge_to_index = build_edge_to_index (S, forbidden_colors )
8787 first_neighbor = fill ((0 , 0 , 0 ), nv) # at first no neighbors have been encountered
8888 treated = zeros (Int, nv)
8989 star = Vector {Int} (undef, ne)
9090 hub = Int[] # one hub for each star, including the trivial ones
9191 vertices_in_order = vertices (g, order)
9292
93- # edge_to_index gives an index for each edge
94- # use forbidden_colors (or color) for the offsets of each column
95- offsets = forbidden_colors
96- counter = 0
97- rvS = rowvals (S)
98- for j in axes (S, 2 )
99- for k in nzrange (S, j)
100- i = rvS[k]
101- if i > j
102- counter += 1
103- edge_to_index[k] = counter
104- k2 = S. colptr[i] + offsets[i]
105- edge_to_index[k2] = counter
106- offsets[i] += 1
107- end
108- end
109- end
110- fill! (offsets, 0 )
111- # Note that we don't need to do that for bicoloring,
112- # we can build that in the same time than the transposed sparsity pattern of A
113-
11493 for v in vertices_in_order
11594 for (iw, w) in enumerate (neighbors2 (g, v))
11695 (v == w || iszero (color[w])) && continue
@@ -257,33 +236,12 @@ function acyclic_coloring(g::AdjacencyGraph, order::AbstractOrder, postprocessin
257236 ne = nb_edges (g)
258237 color = zeros (Int, nv)
259238 forbidden_colors = zeros (Int, nv)
260- edge_to_index = Vector {Int} (undef, nnz (S) )
239+ edge_to_index = build_edge_to_index (S, forbidden_colors )
261240 first_neighbor = fill ((0 , 0 , 0 ), nv) # at first no neighbors have been encountered
262241 first_visit_to_tree = fill ((0 , 0 ), ne)
263242 forest = Forest {Int} (ne)
264243 vertices_in_order = vertices (g, order)
265244
266- # edge_to_index gives an index for each edge
267- # use forbidden_colors (or color) for the offsets of each column
268- offsets = forbidden_colors
269- counter = 0
270- rvS = rowvals (S)
271- for j in axes (S, 2 )
272- for k in nzrange (S, j)
273- i = rvS[k]
274- if i > j
275- counter += 1
276- edge_to_index[k] = counter
277- k2 = S. colptr[i] + offsets[i]
278- edge_to_index[k2] = counter
279- offsets[i] += 1
280- end
281- end
282- end
283- fill! (offsets, 0 )
284- # Note that we don't need to do that for bicoloring,
285- # we can build that in the same time than the transposed sparsity pattern of A
286-
287245 for v in vertices_in_order
288246 for w in neighbors (g, v)
289247 iszero (color[w]) && continue
0 commit comments