Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
IoannisPanagiotas committed Aug 30, 2024
1 parent 79c624c commit 0497016
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,4 @@
*/
package org.neo4j.gds.modularity;

import org.neo4j.gds.annotation.ValueClass;

@ValueClass
public interface CommunityModularity {

long communityId();
double modularity();

static CommunityModularity of(long communityId, double modularity) {
return ImmutableCommunityModularity.of(communityId, modularity);
}

}
public record CommunityModularity(long communityId, double modularity){}
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public ModularityResult compute() {
var Kc = totalCommunityRelationships.get(mappedCommunityId);
var modularity = (ec - Kc * Kc * (1.0 / totalRelWeight)) / totalRelWeight;
totalModularity.add(modularity);
communityModularities.set(resultIndex++, CommunityModularity.of(communityId, modularity));
communityModularities.set(resultIndex++, new CommunityModularity(communityId, modularity));
}

return new ModularityResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ void compute(String communityId, int startingId) {

assertThat(modularities)
.containsExactlyInAnyOrder(
CommunityModularity.of(startingId, community_0_score),
CommunityModularity.of(startingId + 5L, community_5_score)
new CommunityModularity(startingId, community_0_score),
new CommunityModularity(startingId + 5L, community_5_score)
);
}

Expand Down

0 comments on commit 0497016

Please sign in to comment.