### Question:
UniformNeighborhoodSampler { public List<Long> sample(Graph graph, long nodeId, long numberOfSamples, long randomState) { AtomicLong remainingToSample = new AtomicLong(numberOfSamples); AtomicLong remainingToConsider = new AtomicLong(graph.degree(nodeId)); List<Long> neighbors = new ArrayList<>(); graph.concurrentCopy().forEachRelationship( nodeId, (source, target) -> { if (remainingToSample.get() == 0 || remainingToConsider.get() == 0) { return false; } double randomDouble = randomDouble(randomState, source, target, graph.nodeCount()); if (remainingToConsider.getAndDecrement() * randomDouble <= remainingToSample.get()) { neighbors.add(target); remainingToSample.decrementAndGet(); } return true; } ); return neighbors; } UniformNeighborhoodSampler(); List<Long> sample(Graph graph, long nodeId, long numberOfSamples, long randomState);  }### Answer:
@Test void shouldSampleSubsetOfNeighbors() { UniformNeighborhoodSampler sampler = new UniformNeighborhoodSampler(); int numberOfSamples = 3; List<Long> sample = sampler.sample(graph, 3L, numberOfSamples, 0); assertNotNull(sample); assertEquals(numberOfSamples, sample.size()); sample.retainAll(List.of(0, 1, 2, 3, 5, 6, 7)); assertEquals(0, sample.size()); }
@Test void shouldSampleAllNeighborsWhenNumberOfSamplesAreGreater() { UniformNeighborhoodSampler sampler = new UniformNeighborhoodSampler(); int numberOfSamples = 19; List<Long> sample = sampler.sample(graph, 3L, numberOfSamples, 0); assertNotNull(sample); assertEquals(4, sample.size()); }