@Test void shouldCreateCorrectNumberOfRandomEdges() { final int potentialNumEdges = 55; final int desiredNumEdges = 45; assertThat(getRandomEdges(potentialNumEdges, desiredNumEdges)) .hasSize(desiredNumEdges); }
static List<WeightedEdge> getRandomEdges(final int potentialNumEdges, final int desiredNumEdges) { return RANDOM.ints(0, potentialNumEdges) .distinct() .mapToObj(RefineClusterImpl::createGaussPair) .filter(RefineClusterImpl::isNotSelfPair) .map(p -> WeightedEdge.of(p.getLeft(), p.getRight(), Double.NaN)) .limit(desiredNumEdges) .collect(Collectors.toList()); }
RefineClusterImpl implements RefineCluster<C, T> { static List<WeightedEdge> getRandomEdges(final int potentialNumEdges, final int desiredNumEdges) { return RANDOM.ints(0, potentialNumEdges) .distinct() .mapToObj(RefineClusterImpl::createGaussPair) .filter(RefineClusterImpl::isNotSelfPair) .map(p -> WeightedEdge.of(p.getLeft(), p.getRight(), Double.NaN)) .limit(desiredNumEdges) .collect(Collectors.toList()); } }
RefineClusterImpl implements RefineCluster<C, T> { static List<WeightedEdge> getRandomEdges(final int potentialNumEdges, final int desiredNumEdges) { return RANDOM.ints(0, potentialNumEdges) .distinct() .mapToObj(RefineClusterImpl::createGaussPair) .filter(RefineClusterImpl::isNotSelfPair) .map(p -> WeightedEdge.of(p.getLeft(), p.getRight(), Double.NaN)) .limit(desiredNumEdges) .collect(Collectors.toList()); }  }
RefineClusterImpl implements RefineCluster<C, T> { static List<WeightedEdge> getRandomEdges(final int potentialNumEdges, final int desiredNumEdges) { return RANDOM.ints(0, potentialNumEdges) .distinct() .mapToObj(RefineClusterImpl::createGaussPair) .filter(RefineClusterImpl::isNotSelfPair) .map(p -> WeightedEdge.of(p.getLeft(), p.getRight(), Double.NaN)) .limit(desiredNumEdges) .collect(Collectors.toList()); }  Stream<Cluster<C, T>> refine(final Stream<? extends Cluster<C, T>> clusters,
            final @NonNull Stream<ClassifiedCandidate<T>> knownClassifications); }
RefineClusterImpl implements RefineCluster<C, T> { static List<WeightedEdge> getRandomEdges(final int potentialNumEdges, final int desiredNumEdges) { return RANDOM.ints(0, potentialNumEdges) .distinct() .mapToObj(RefineClusterImpl::createGaussPair) .filter(RefineClusterImpl::isNotSelfPair) .map(p -> WeightedEdge.of(p.getLeft(), p.getRight(), Double.NaN)) .limit(desiredNumEdges) .collect(Collectors.toList()); }  Stream<Cluster<C, T>> refine(final Stream<? extends Cluster<C, T>> clusters,
            final @NonNull Stream<ClassifiedCandidate<T>> knownClassifications);  }