@@ -76,7 +76,7 @@ _start_neighbors(i::Int, g::UndirectedGraph) = g.offsets[i]
76
76
function UndirectedGraph (I, J, nel)
77
77
adjcount = zeros (Int, nel)
78
78
n_edges = 0
79
- for k in 1 : length (I)
79
+ for k in eachindex (I)
80
80
i = I[k]
81
81
j = J[k]
82
82
if i == j
@@ -96,7 +96,7 @@ function UndirectedGraph(I, J, nel)
96
96
adjlist = Vector {Int} (undef, offsets[nel+ 1 ] - 1 )
97
97
edgeindex = Vector {Int} (undef, length (adjlist))
98
98
edge_count = 0
99
- for k in 1 : length (I)
99
+ for k in eachindex (I)
100
100
i = I[k]
101
101
j = J[k]
102
102
if i == j
@@ -306,7 +306,7 @@ function recovery_preprocess(
306
306
seen_twocolors = 0
307
307
# count of edges in each subgraph
308
308
edge_count = Int[]
309
- for k in 1 : length (g. edges)
309
+ for k in eachindex (g. edges)
310
310
u, v = g. edges[k]
311
311
i = min (color[u], color[v])
312
312
j = max (color[u], color[v])
@@ -324,7 +324,7 @@ function recovery_preprocess(
324
324
sorted_edges[idx] = Tuple{Int,Int}[]
325
325
sizehint! (sorted_edges[idx], edge_count[idx])
326
326
end
327
- for i in 1 : length (g. edges)
327
+ for i in eachindex (g. edges)
328
328
u, v = g. edges[i]
329
329
i = min (color[u], color[v])
330
330
j = max (color[u], color[v])
@@ -343,7 +343,7 @@ function recovery_preprocess(
343
343
my_edges = sorted_edges[idx]
344
344
vlist = Int[]
345
345
# build up the vertex list and adjacency count
346
- for k in 1 : length (my_edges)
346
+ for k in eachindex (my_edges)
347
347
u, v = my_edges[k]
348
348
# seen these vertices yet?
349
349
if revmap[u] == 0
@@ -362,7 +362,7 @@ function recovery_preprocess(
362
362
# set up offsets for adjlist
363
363
offset = Vector {Int} (undef, length (vlist) + 1 )
364
364
offset[1 ] = 1
365
- for k in 1 : length (vlist)
365
+ for k in eachindex (vlist)
366
366
offset[k+ 1 ] = offset[k] + adjcount[vlist[k]]
367
367
adjcount[vlist[k]] = 0
368
368
end
@@ -371,7 +371,7 @@ function recovery_preprocess(
371
371
# u has global index vlist[u]
372
372
vec = Vector {Int} (undef, offset[length (vlist)+ 1 ] - 1 )
373
373
# now fill in
374
- for k in 1 : length (my_edges)
374
+ for k in eachindex (my_edges)
375
375
u, v = my_edges[k]
376
376
u_rev = revmap[u] # indices in the subgraph
377
377
v_rev = revmap[v]
@@ -383,7 +383,7 @@ function recovery_preprocess(
383
383
resize! (cmap, length (vlist))
384
384
order, parent =
385
385
reverse_topological_sort_by_dfs (vec, offset, length (vlist), cmap)
386
- for k in 1 : length (vlist)
386
+ for k in eachindex (vlist)
387
387
revmap[vlist[k]] = 0 # clear for reuse
388
388
end
389
389
postorder[idx] = order
@@ -412,11 +412,11 @@ function _indirect_recover_structure(rinfo::RecoveryInfo)
412
412
k += 1
413
413
I[k] = J[k] = i
414
414
end
415
- for t in 1 : length (rinfo. postorder)
415
+ for t in eachindex (rinfo. postorder)
416
416
vmap = rinfo. vertexmap[t]
417
417
order = rinfo. postorder[t]
418
418
parent = rinfo. parents[t]
419
- for z in 1 : length (order)
419
+ for z in eachindex (order)
420
420
v = order[z]
421
421
p = parent[v]
422
422
if p == 0
@@ -456,11 +456,11 @@ function hessian_color_preprocess(
456
456
local_indices = sort! (seen_idx. nzidx[1 : seen_idx. nnz])
457
457
empty! (seen_idx)
458
458
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)
460
460
global_to_local_idx[local_indices[k]] = k
461
461
end
462
462
# only do the coloring on the local indices
463
- for k in 1 : length (I)
463
+ for k in eachindex (I)
464
464
I[k] = global_to_local_idx[I[k]]
465
465
J[k] = global_to_local_idx[J[k]]
466
466
end
@@ -470,7 +470,7 @@ function hessian_color_preprocess(
470
470
rinfo = recovery_preprocess (g, color, num_colors, local_indices)
471
471
I, J = _indirect_recover_structure (rinfo)
472
472
# convert back to global indices
473
- for k in 1 : length (I)
473
+ for k in eachindex (I)
474
474
I[k] = local_indices[I[k]]
475
475
J[k] = local_indices[J[k]]
476
476
end
@@ -525,14 +525,14 @@ function recover_from_matmat!(
525
525
k += 1
526
526
V[k] = R[i, rinfo. color[i]]
527
527
end
528
- for t in 1 : length (rinfo. vertexmap)
528
+ for t in eachindex (rinfo. vertexmap)
529
529
vmap = rinfo. vertexmap[t]
530
530
order = rinfo. postorder[t]
531
531
parent = rinfo. parents[t]
532
- for z in 1 : length (order)
532
+ for z in eachindex (order)
533
533
@inbounds stored_values[z] = 0.0
534
534
end
535
- @inbounds for z in 1 : length (order)
535
+ @inbounds for z in eachindex (order)
536
536
v = order[z]
537
537
p = parent[v]
538
538
if p == 0
0 commit comments