### Question:
ANNUtils { public static long[] sampleNeighbors(long[] potentialNeighbors, double initialSampleSize, Random random) { shuffleArray(potentialNeighbors, random); int sampleSize = (int) Math.min(initialSampleSize, potentialNeighbors.length); long[] sampled = new long[sampleSize]; System.arraycopy(potentialNeighbors, 0, sampled, 0, sampleSize); return sampled; }  static long[] sampleNeighbors(long[] potentialNeighbors, double initialSampleSize, Random random); static Set<Integer> selectRandomNeighbors(
            final int topK, final int numberOfInputs, final int excludeIndex,
            final Random random);  }### Answer:
@Test public void sampleNeighbors() { assertEquals(3, ANNUtils.sampleNeighbors(new long[] {1L, 3L, 5L, 7L}, 3, new Random()).length); assertEquals(2, ANNUtils.sampleNeighbors(new long[] {1L, 3L}, 3, new Random()).length); }