Ah yes. The code here was actually correct, but didn’t behave well for size=2.

What’s being changed, effectively, is sampling with replacement instead of without. I agree this is probably better.

The comments need to be changed, though. Something like “pick a random node with which we can swap n” since we are no longer picking from the shrunk heap.