class 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;
    }

    public  UniformNeighborhoodSampler();

}