Skip to content

Commit

Permalink
From Centrality to Community :oops:
Browse files Browse the repository at this point in the history
  • Loading branch information
IoannisPanagiotas committed Nov 7, 2024
1 parent 60c54bf commit c760731
Show file tree
Hide file tree
Showing 44 changed files with 298 additions and 282 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.neo4j.gds.executor.ExecutionMode;
import org.neo4j.gds.executor.GdsCallable;
import org.neo4j.gds.mem.MemoryEstimation;
import org.neo4j.gds.procedures.algorithms.centrality.SpeakerListenerLPAMutateResult;
import org.neo4j.gds.procedures.algorithms.community.SpeakerListenerLPAMutateResult;
import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction;
import org.neo4j.gds.sllpa.SpeakerListenerLPA;
import org.neo4j.gds.sllpa.SpeakerListenerLPAConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.neo4j.gds.executor.ExecutionMode;
import org.neo4j.gds.executor.GdsCallable;
import org.neo4j.gds.mem.MemoryEstimation;
import org.neo4j.gds.procedures.algorithms.centrality.SpeakerListenerLPAStatsResult;
import org.neo4j.gds.procedures.algorithms.community.SpeakerListenerLPAStatsResult;
import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction;
import org.neo4j.gds.sllpa.SpeakerListenerLPA;
import org.neo4j.gds.sllpa.SpeakerListenerLPAConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.neo4j.gds.executor.ExecutionMode;
import org.neo4j.gds.executor.GdsCallable;
import org.neo4j.gds.mem.MemoryEstimation;
import org.neo4j.gds.procedures.algorithms.centrality.SpeakerListenerLPAStreamResult;
import org.neo4j.gds.procedures.algorithms.community.SpeakerListenerLPAStreamResult;
import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction;
import org.neo4j.gds.sllpa.SpeakerListenerLPA;
import org.neo4j.gds.sllpa.SpeakerListenerLPAConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.neo4j.gds.executor.ExecutionMode;
import org.neo4j.gds.executor.GdsCallable;
import org.neo4j.gds.mem.MemoryEstimation;
import org.neo4j.gds.procedures.algorithms.centrality.SpeakerListenerLPAWriteResult;
import org.neo4j.gds.procedures.algorithms.community.SpeakerListenerLPAWriteResult;
import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction;
import org.neo4j.gds.sllpa.SpeakerListenerLPA;
import org.neo4j.gds.sllpa.SpeakerListenerLPAConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.neo4j.gds.articulationpoints.ArticulationPoints;
import org.neo4j.gds.articulationpoints.ArticulationPointsProgressTaskCreator;
import org.neo4j.gds.beta.pregel.Pregel;
import org.neo4j.gds.beta.pregel.PregelResult;
import org.neo4j.gds.betweenness.BetweennessCentrality;
import org.neo4j.gds.betweenness.BetweennessCentralityBaseConfig;
import org.neo4j.gds.betweenness.BetwennessCentralityResult;
Expand Down Expand Up @@ -68,13 +67,8 @@
import org.neo4j.gds.pagerank.PageRankComputation;
import org.neo4j.gds.pagerank.PageRankConfig;
import org.neo4j.gds.pagerank.PageRankResult;
import org.neo4j.gds.sllpa.SpeakerListenerLPA;
import org.neo4j.gds.sllpa.SpeakerListenerLPAConfig;
import org.neo4j.gds.sllpa.SpeakerListenerLPAProgressTrackerCreator;
import org.neo4j.gds.termination.TerminationFlag;

import java.util.Optional;

import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.ArticleRank;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.EigenVector;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.PageRank;
Expand Down Expand Up @@ -344,18 +338,5 @@ private PageRankComputation pageRankComputation(Graph graph, PageRankConfig conf
return new PageRankComputation(configuration, mappedSourceNodes, degreeFunction);
}

PregelResult speakerListenerLPA(Graph graph, SpeakerListenerLPAConfig configuration){
var task =SpeakerListenerLPAProgressTrackerCreator.progressTask(graph.nodeCount(),configuration.maxIterations(),AlgorithmLabel.SLLPA.asString());
var progressTracker = progressTrackerCreator.createProgressTracker(configuration, task);

var algorithm = new SpeakerListenerLPA(
graph,
configuration,
DefaultPool.INSTANCE,
progressTracker,
Optional.empty()
);

return algorithmMachinery.runAlgorithmsAndManageProgressTracker(algorithm, progressTracker, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
import org.neo4j.gds.mem.MemoryEstimation;
import org.neo4j.gds.pagerank.PageRankMemoryEstimateDefinition;
import org.neo4j.gds.pagerank.RankConfig;
import org.neo4j.gds.sllpa.SpeakerListenerLPAConfig;
import org.neo4j.gds.sllpa.SpeakerListenerLPAMemoryEstimateDefinition;

public class CentralityAlgorithmsEstimationModeBusinessFacade {
private final AlgorithmEstimationTemplate algorithmEstimationTemplate;
Expand Down Expand Up @@ -156,17 +154,5 @@ MemoryEstimation indirectExposure() {
}


public MemoryEstimation speakerListenerLPA() {
return new SpeakerListenerLPAMemoryEstimateDefinition().memoryEstimation();
}

public MemoryEstimateResult speakerListenerLPA(SpeakerListenerLPAConfig configuration, Object graphNameOrConfiguration) {
var memoryEstimation = speakerListenerLPA();

return algorithmEstimationTemplate.estimate(
configuration,
graphNameOrConfiguration,
memoryEstimation
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.neo4j.gds.applications.algorithms.machinery.ResultBuilder;
import org.neo4j.gds.applications.algorithms.metadata.NodePropertiesWritten;
import org.neo4j.gds.articulationpoints.ArticulationPointsMutateConfig;
import org.neo4j.gds.beta.pregel.PregelResult;
import org.neo4j.gds.betweenness.BetweennessCentralityMutateConfig;
import org.neo4j.gds.betweenness.BetwennessCentralityResult;
import org.neo4j.gds.closeness.ClosenessCentralityMutateConfig;
Expand All @@ -43,7 +42,6 @@
import org.neo4j.gds.pagerank.EigenvectorMutateConfig;
import org.neo4j.gds.pagerank.PageRankMutateConfig;
import org.neo4j.gds.pagerank.PageRankResult;
import org.neo4j.gds.sllpa.SpeakerListenerLPAConfig;

import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.ArticleRank;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.ArticulationPoints;
Expand All @@ -55,7 +53,6 @@
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.HarmonicCentrality;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.IndirectExposure;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.PageRank;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.SLLPA;

public class CentralityAlgorithmsMutateModeBusinessFacade {
private final CentralityAlgorithmsEstimationModeBusinessFacade estimation;
Expand Down Expand Up @@ -256,21 +253,5 @@ public <RESULT> RESULT indirectExposure(
);
}

public <RESULT> RESULT speakerListenerLPA(
GraphName graphName,
SpeakerListenerLPAConfig configuration,
ResultBuilder<SpeakerListenerLPAConfig, PregelResult, RESULT, NodePropertiesWritten> resultBuilder
) {
var mutateStep = new SpeakerListenerLPAMutateStep(mutateNodeProperty, configuration);

return algorithmProcessingTemplateConvenience.processRegularAlgorithmInMutateMode(
graphName,
configuration,
SLLPA,
estimation::indirectExposure,
(graph, __) -> algorithms.speakerListenerLPA(graph, configuration),
mutateStep,
resultBuilder
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.neo4j.gds.applications.algorithms.machinery.AlgorithmProcessingTemplateConvenience;
import org.neo4j.gds.applications.algorithms.machinery.StatsResultBuilder;
import org.neo4j.gds.articulationpoints.ArticulationPointsStatsConfig;
import org.neo4j.gds.beta.pregel.PregelResult;
import org.neo4j.gds.betweenness.BetweennessCentralityStatsConfig;
import org.neo4j.gds.closeness.ClosenessCentralityStatsConfig;
import org.neo4j.gds.degree.DegreeCentralityStatsConfig;
Expand All @@ -36,7 +35,6 @@
import org.neo4j.gds.pagerank.EigenvectorStatsConfig;
import org.neo4j.gds.pagerank.PageRankResult;
import org.neo4j.gds.pagerank.PageRankStatsConfig;
import org.neo4j.gds.sllpa.SpeakerListenerLPAConfig;

import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.ArticleRank;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.ArticulationPoints;
Expand All @@ -47,7 +45,6 @@
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.EigenVector;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.HarmonicCentrality;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.PageRank;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.SLLPA;

public class CentralityAlgorithmsStatsModeBusinessFacade {
private final CentralityAlgorithmsEstimationModeBusinessFacade estimationFacade;
Expand Down Expand Up @@ -199,18 +196,5 @@ public <RESULT> RESULT pageRank(
);
}

public <RESULT> RESULT sllpa(
GraphName graphName,
SpeakerListenerLPAConfig configuration,
StatsResultBuilder<PregelResult, RESULT> resultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStatsMode(
graphName,
configuration,
SLLPA,
estimationFacade::speakerListenerLPA,
(graph, __) -> centralityAlgorithms.speakerListenerLPA(graph, configuration),
resultBuilder
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.neo4j.gds.applications.algorithms.machinery.AlgorithmProcessingTemplateConvenience;
import org.neo4j.gds.applications.algorithms.machinery.StreamResultBuilder;
import org.neo4j.gds.articulationpoints.ArticulationPointsStreamConfig;
import org.neo4j.gds.beta.pregel.PregelResult;
import org.neo4j.gds.betweenness.BetweennessCentralityStreamConfig;
import org.neo4j.gds.bridges.BridgeResult;
import org.neo4j.gds.bridges.BridgesStreamConfig;
Expand All @@ -39,7 +38,6 @@
import org.neo4j.gds.pagerank.EigenvectorStreamConfig;
import org.neo4j.gds.pagerank.PageRankResult;
import org.neo4j.gds.pagerank.PageRankStreamConfig;
import org.neo4j.gds.sllpa.SpeakerListenerLPAConfig;

import java.util.stream.Stream;

Expand All @@ -53,7 +51,6 @@
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.EigenVector;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.HarmonicCentrality;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.PageRank;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.SLLPA;

public class CentralityAlgorithmsStreamModeBusinessFacade {
private final CentralityAlgorithmsEstimationModeBusinessFacade estimationFacade;
Expand Down Expand Up @@ -220,18 +217,4 @@ public <RESULT> Stream<RESULT> pageRank(
);
}

public <RESULT> Stream<RESULT> sllpa(
GraphName graphName,
SpeakerListenerLPAConfig configuration,
StreamResultBuilder<PregelResult, RESULT> streamResultBuilder
) {
return algorithmProcessingTemplateConvenience.processRegularAlgorithmInStreamMode(
graphName,
configuration,
SLLPA,
estimationFacade::pageRank,
(graph, __) -> centralityAlgorithms.speakerListenerLPA(graph, configuration),
streamResultBuilder
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.neo4j.gds.applications.algorithms.machinery.WriteToDatabase;
import org.neo4j.gds.applications.algorithms.metadata.NodePropertiesWritten;
import org.neo4j.gds.articulationpoints.ArticulationPointsWriteConfig;
import org.neo4j.gds.beta.pregel.PregelResult;
import org.neo4j.gds.betweenness.BetweennessCentralityWriteConfig;
import org.neo4j.gds.closeness.ClosenessCentralityWriteConfig;
import org.neo4j.gds.degree.DegreeCentralityWriteConfig;
Expand All @@ -42,7 +41,6 @@
import org.neo4j.gds.pagerank.EigenvectorWriteConfig;
import org.neo4j.gds.pagerank.PageRankResult;
import org.neo4j.gds.pagerank.PageRankWriteConfig;
import org.neo4j.gds.sllpa.SpeakerListenerLPAConfig;

import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.ArticleRank;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.ArticulationPoints;
Expand All @@ -53,7 +51,6 @@
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.EigenVector;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.HarmonicCentrality;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.PageRank;
import static org.neo4j.gds.applications.algorithms.machinery.AlgorithmLabel.SLLPA;

public final class CentralityAlgorithmsWriteModeBusinessFacade {
private final CentralityAlgorithmsEstimationModeBusinessFacade estimationFacade;
Expand Down Expand Up @@ -251,22 +248,4 @@ public <RESULT> RESULT pageRank(
);
}

public <RESULT> RESULT sllpa(
GraphName graphName,
SpeakerListenerLPAConfig configuration,
ResultBuilder<SpeakerListenerLPAConfig, PregelResult, RESULT, NodePropertiesWritten> resultBuilder
) {
var writeStep = new SpeakerListenerLPAWriteStep(writeToDatabase, configuration, SLLPA);

return algorithmProcessingTemplateConvenience.processRegularAlgorithmInWriteMode(
graphName,
configuration,
SLLPA,
estimationFacade::speakerListenerLPA,
(graph, __) -> centralityAlgorithms.speakerListenerLPA(graph, configuration),
writeStep,
resultBuilder
);
}

}
1 change: 1 addition & 0 deletions applications/algorithms/community/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies {
implementation project(":graph-schema-api")
implementation project(":logging")
implementation project(":memory-usage")
implementation project(":pregel")
implementation project(":progress-tracking")
implementation project(":termination")
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.neo4j.gds.approxmaxkcut.ApproxMaxKCut;
import org.neo4j.gds.approxmaxkcut.ApproxMaxKCutResult;
import org.neo4j.gds.approxmaxkcut.config.ApproxMaxKCutBaseConfig;
import org.neo4j.gds.beta.pregel.PregelResult;
import org.neo4j.gds.collections.ha.HugeLongArray;
import org.neo4j.gds.conductance.Conductance;
import org.neo4j.gds.conductance.ConductanceBaseConfig;
Expand Down Expand Up @@ -68,6 +69,9 @@
import org.neo4j.gds.modularityoptimization.ModularityOptimizationResult;
import org.neo4j.gds.scc.Scc;
import org.neo4j.gds.scc.SccCommonBaseConfig;
import org.neo4j.gds.sllpa.SpeakerListenerLPA;
import org.neo4j.gds.sllpa.SpeakerListenerLPAConfig;
import org.neo4j.gds.sllpa.SpeakerListenerLPAProgressTrackerCreator;
import org.neo4j.gds.termination.TerminationFlag;
import org.neo4j.gds.triangle.IntersectingTriangleCount;
import org.neo4j.gds.triangle.IntersectingTriangleCountFactory;
Expand All @@ -76,8 +80,8 @@
import org.neo4j.gds.triangle.LocalClusteringCoefficientResult;
import org.neo4j.gds.triangle.TriangleCountBaseConfig;
import org.neo4j.gds.triangle.TriangleCountResult;
import org.neo4j.gds.triangle.TriangleStream;
import org.neo4j.gds.triangle.TriangleResult;
import org.neo4j.gds.triangle.TriangleStream;
import org.neo4j.gds.wcc.Wcc;
import org.neo4j.gds.wcc.WccBaseConfig;

Expand Down Expand Up @@ -489,4 +493,19 @@ private K1ColoringBaseConfig createModularityConfig() {
.build();

}

PregelResult speakerListenerLPA(Graph graph, SpeakerListenerLPAConfig configuration){
var task = SpeakerListenerLPAProgressTrackerCreator.progressTask(graph.nodeCount(),configuration.maxIterations(),AlgorithmLabel.SLLPA.asString());
var progressTracker = progressTrackerCreator.createProgressTracker(configuration, task);

var algorithm = new SpeakerListenerLPA(
graph,
configuration,
DefaultPool.INSTANCE,
progressTracker,
Optional.empty()
);

return algorithmMachinery.runAlgorithmsAndManageProgressTracker(algorithm, progressTracker, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import org.neo4j.gds.modularityoptimization.ModularityOptimizationMemoryEstimateDefinition;
import org.neo4j.gds.scc.SccBaseConfig;
import org.neo4j.gds.scc.SccMemoryEstimateDefinition;
import org.neo4j.gds.sllpa.SpeakerListenerLPAConfig;
import org.neo4j.gds.sllpa.SpeakerListenerLPAMemoryEstimateDefinition;
import org.neo4j.gds.triangle.IntersectingTriangleCountMemoryEstimateDefinition;
import org.neo4j.gds.triangle.LocalClusteringCoefficientBaseConfig;
import org.neo4j.gds.triangle.LocalClusteringCoefficientMemoryEstimateDefinition;
Expand Down Expand Up @@ -259,4 +261,18 @@ public MemoryEstimateResult wcc(WccBaseConfig configuration, Object graphNameOrC
memoryEstimation
);
}

public MemoryEstimation speakerListenerLPA() {
return new SpeakerListenerLPAMemoryEstimateDefinition().memoryEstimation();
}

public MemoryEstimateResult speakerListenerLPA(SpeakerListenerLPAConfig configuration, Object graphNameOrConfiguration) {
var memoryEstimation = speakerListenerLPA();

return algorithmEstimationTemplate.estimate(
configuration,
graphNameOrConfiguration,
memoryEstimation
);
}
}
Loading

0 comments on commit c760731

Please sign in to comment.