In encoding java.util.Random is used to generate random indexes of neighbors. Random number generated this way is not guaranteed to be non-repeating, hence it could happen that two (or more) neighbors are actually the same and gets cancelled out by xor, wasting time and reducing the actual neighbors count
Suggest to check for any repeats in neighbors index