Skip to content

Commit

Permalink
Fix community count computation for long based ids
Browse files Browse the repository at this point in the history
Co-Authored-By: Paul Horn <paul.horn@neotechnology.com>
  • Loading branch information
jjaderberg and knutwalker committed Jul 28, 2020
1 parent 0c80df0 commit bd2cf24
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void buildCommunityCount() {
long communityCount = 0L;

SparseNodeMapping componentSizes = buildComponentSizes();
for (int communityId = 0; communityId < componentSizes.getCapacity(); communityId++) {
for (long communityId = 0; communityId < componentSizes.getCapacity(); communityId++) {
long communitySize = componentSizes.get(communityId);
if (communitySize > 0) {
communityCount++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,24 @@ void oneCommunityFromHugeMap() {
assertEquals(4.0, histogram.getValueAtPercentile(100D), 0.01);
}

@Test
void buildCommunityCountWithHugeCommunityCount() {
AbstractCommunityResultBuilder<Void> builder = builder(
procedureCallContext("communityCount"),
(maybeCommunityCount, maybeHistogram) -> {
assertTrue(maybeCommunityCount.isPresent());
assertFalse(maybeHistogram.isPresent());
long communityCount = maybeCommunityCount.orElse(-1);
assertEquals(2L, communityCount, "should build 2 communities");
});

LongUnaryOperator communityFunction = n -> n % 2 == 0 ? 0 : ((long) Integer.MAX_VALUE) + 2;
builder
.withCommunityFunction(communityFunction)
.withNodeCount(2)
.build();
}

@Test
void buildCommunityHistogramWithHugeCommunityCount() {
AbstractCommunityResultBuilder<Void> builder = builder(
Expand Down

0 comments on commit bd2cf24

Please sign in to comment.