@@ -210,39 +210,39 @@ function update_bucket!(db::DegreeBuckets, v::Integer; degtype, direction)
210
210
low, high = bucket_low[d + 1 ], bucket_high[d + 1 ]
211
211
# select previous or next bucket for the move
212
212
if degree_increasing (; degtype, direction)
213
- # put v at the end of its bucket by swapping
213
+ # move the vertex w located at the end of the current bucket to v's position
214
214
w = bucket_storage[high]
215
215
bucket_storage[p] = w
216
- bucket_storage[high] = v
217
216
positions[w] = p
218
- positions[v] = high
219
- # move v to the beginning of the next bucket (mind the gap)
217
+ # shrink current bucket from the right
218
+ # morally we put v at the end and then ignore it
219
+ bucket_high[d + 1 ] -= 1
220
+ # move v to the beginning of the next bucket (!= ColPack)
220
221
d_new = d + 1
221
222
low_new, high_new = bucket_low[d_new + 1 ], bucket_high[d_new + 1 ]
222
223
bucket_storage[low_new - 1 ] = v
223
- # update v stats
224
+ # grow next bucket to the left
225
+ bucket_low[d_new + 1 ] -= 1
226
+ # update v's stats
224
227
degrees[v] = d_new
225
228
positions[v] = low_new - 1
226
- # grow next bucket to the left, shrink current one from the right
227
- bucket_low[d_new + 1 ] -= 1
228
- bucket_high[d + 1 ] -= 1
229
229
else
230
- # put v at the beginning of its bucket by swapping
230
+ # move the vertex w located at the start of the current bucket to v's position (!= ColPack)
231
231
w = bucket_storage[low]
232
232
bucket_storage[p] = w
233
- bucket_storage[low] = v
234
233
positions[w] = p
235
- positions[v] = low
236
- # move v to the end of the previous bucket (mind the gap)
234
+ # shrink current bucket from the left
235
+ # morally we put v at the start and then ignore it
236
+ bucket_low[d + 1 ] += 1
237
+ # move v to the end of the previous bucket
237
238
d_new = d - 1
238
239
low_new, high_new = bucket_low[d_new + 1 ], bucket_high[d_new + 1 ]
239
240
bucket_storage[high_new + 1 ] = v
240
- # update v stats
241
+ # grow previous bucket to the right
242
+ bucket_high[d_new + 1 ] += 1
243
+ # update v's stats
241
244
degrees[v] = d_new
242
245
positions[v] = high_new + 1
243
- # grow previous bucket to the right, shrink current one from the left
244
- bucket_high[d_new + 1 ] += 1
245
- bucket_low[d + 1 ] += 1
246
246
end
247
247
return nothing
248
248
end
0 commit comments