@@ -76,7 +76,7 @@ _start_neighbors(i::Int, g::UndirectedGraph) = g.offsets[i]
7676function UndirectedGraph (I, J, nel)
7777 adjcount = zeros (Int, nel)
7878 n_edges = 0
79- for k in 1 : length (I)
79+ for k in eachindex (I)
8080 i = I[k]
8181 j = J[k]
8282 if i == j
@@ -96,7 +96,7 @@ function UndirectedGraph(I, J, nel)
9696 adjlist = Vector {Int} (undef, offsets[nel+ 1 ] - 1 )
9797 edgeindex = Vector {Int} (undef, length (adjlist))
9898 edge_count = 0
99- for k in 1 : length (I)
99+ for k in eachindex (I)
100100 i = I[k]
101101 j = J[k]
102102 if i == j
@@ -306,7 +306,7 @@ function recovery_preprocess(
306306 seen_twocolors = 0
307307 # count of edges in each subgraph
308308 edge_count = Int[]
309- for k in 1 : length (g. edges)
309+ for k in eachindex (g. edges)
310310 u, v = g. edges[k]
311311 i = min (color[u], color[v])
312312 j = max (color[u], color[v])
@@ -324,7 +324,7 @@ function recovery_preprocess(
324324 sorted_edges[idx] = Tuple{Int,Int}[]
325325 sizehint! (sorted_edges[idx], edge_count[idx])
326326 end
327- for i in 1 : length (g. edges)
327+ for i in eachindex (g. edges)
328328 u, v = g. edges[i]
329329 i = min (color[u], color[v])
330330 j = max (color[u], color[v])
@@ -343,7 +343,7 @@ function recovery_preprocess(
343343 my_edges = sorted_edges[idx]
344344 vlist = Int[]
345345 # build up the vertex list and adjacency count
346- for k in 1 : length (my_edges)
346+ for k in eachindex (my_edges)
347347 u, v = my_edges[k]
348348 # seen these vertices yet?
349349 if revmap[u] == 0
@@ -362,7 +362,7 @@ function recovery_preprocess(
362362 # set up offsets for adjlist
363363 offset = Vector {Int} (undef, length (vlist) + 1 )
364364 offset[1 ] = 1
365- for k in 1 : length (vlist)
365+ for k in eachindex (vlist)
366366 offset[k+ 1 ] = offset[k] + adjcount[vlist[k]]
367367 adjcount[vlist[k]] = 0
368368 end
@@ -371,7 +371,7 @@ function recovery_preprocess(
371371 # u has global index vlist[u]
372372 vec = Vector {Int} (undef, offset[length (vlist)+ 1 ] - 1 )
373373 # now fill in
374- for k in 1 : length (my_edges)
374+ for k in eachindex (my_edges)
375375 u, v = my_edges[k]
376376 u_rev = revmap[u] # indices in the subgraph
377377 v_rev = revmap[v]
@@ -383,7 +383,7 @@ function recovery_preprocess(
383383 resize! (cmap, length (vlist))
384384 order, parent =
385385 reverse_topological_sort_by_dfs (vec, offset, length (vlist), cmap)
386- for k in 1 : length (vlist)
386+ for k in eachindex (vlist)
387387 revmap[vlist[k]] = 0 # clear for reuse
388388 end
389389 postorder[idx] = order
@@ -412,11 +412,11 @@ function _indirect_recover_structure(rinfo::RecoveryInfo)
412412 k += 1
413413 I[k] = J[k] = i
414414 end
415- for t in 1 : length (rinfo. postorder)
415+ for t in eachindex (rinfo. postorder)
416416 vmap = rinfo. vertexmap[t]
417417 order = rinfo. postorder[t]
418418 parent = rinfo. parents[t]
419- for z in 1 : length (order)
419+ for z in eachindex (order)
420420 v = order[z]
421421 p = parent[v]
422422 if p == 0
@@ -456,11 +456,11 @@ function hessian_color_preprocess(
456456 local_indices = sort! (seen_idx. nzidx[1 : seen_idx. nnz])
457457 empty! (seen_idx)
458458 global_to_local_idx = seen_idx. nzidx # steal for storage
459- for k in 1 : length (local_indices)
459+ for k in eachindex (local_indices)
460460 global_to_local_idx[local_indices[k]] = k
461461 end
462462 # only do the coloring on the local indices
463- for k in 1 : length (I)
463+ for k in eachindex (I)
464464 I[k] = global_to_local_idx[I[k]]
465465 J[k] = global_to_local_idx[J[k]]
466466 end
@@ -470,7 +470,7 @@ function hessian_color_preprocess(
470470 rinfo = recovery_preprocess (g, color, num_colors, local_indices)
471471 I, J = _indirect_recover_structure (rinfo)
472472 # convert back to global indices
473- for k in 1 : length (I)
473+ for k in eachindex (I)
474474 I[k] = local_indices[I[k]]
475475 J[k] = local_indices[J[k]]
476476 end
@@ -525,14 +525,14 @@ function recover_from_matmat!(
525525 k += 1
526526 V[k] = R[i, rinfo. color[i]]
527527 end
528- for t in 1 : length (rinfo. vertexmap)
528+ for t in eachindex (rinfo. vertexmap)
529529 vmap = rinfo. vertexmap[t]
530530 order = rinfo. postorder[t]
531531 parent = rinfo. parents[t]
532- for z in 1 : length (order)
532+ for z in eachindex (order)
533533 @inbounds stored_values[z] = 0.0
534534 end
535- @inbounds for z in 1 : length (order)
535+ @inbounds for z in eachindex (order)
536536 v = order[z]
537537 p = parent[v]
538538 if p == 0
0 commit comments