@@ -343,17 +343,19 @@ function vertices(
343343 db = DegreeBuckets (
344344 T, degrees, max_degrees; reproduce_colpack= order. reproduce_colpack
345345 )
346- π = T[]
347- sizehint! (π, nb_vertices (g))
348- for _ in 1 : nb_vertices (g)
346+ π = Vector {T} (undef, nb_vertices (g))
347+ for index in 1 : nb_vertices (g)
349348 u = pop_next_candidate! (db; direction)
350- direction == :low2high ? push! (π, u) : pushfirst! (π, u)
349+ π[index] = u
351350 for v in neighbors (g, u)
352351 ! has_diagonal (g) || (u == v && continue )
353352 already_ordered (db, v) && continue
354353 update_bucket! (db, v; degtype, direction)
355354 end
356355 end
356+ if direction == :low2high
357+ reverse! (π)
358+ end
357359 return π
358360end
359361
@@ -389,11 +391,10 @@ function vertices(
389391 fill! (degrees, zero (T))
390392 end
391393 db = DegreeBuckets (T, degrees, maxd2; reproduce_colpack= order. reproduce_colpack)
392- π = T[]
393- sizehint! (π, n)
394- for _ in 1 : nb_vertices (g, Val (side))
394+ π = Vector {T} (undef, n)
395+ for index in 1 : nb_vertices (g, Val (side))
395396 u = pop_next_candidate! (db; direction)
396- direction == :low2high ? push! (π, u) : pushfirst! (π, u)
397+ π[index] = u
397398 for w in neighbors (g, Val (side), u)
398399 for v in neighbors (g, Val (other_side), w)
399400 if v != u && ! visited[v]
@@ -411,6 +412,9 @@ function vertices(
411412 end
412413 num_visited = 0
413414 end
415+ if direction == :low2high
416+ reverse! (π)
417+ end
414418 return π
415419end
416420
0 commit comments