Skip to content

Commit

Permalink
Remove auxiliary methods from PageRank configs
Browse files Browse the repository at this point in the history
  • Loading branch information
vnickolov committed Sep 17, 2024
1 parent c68167f commit 73b220f
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,7 @@
@Configuration
public interface PageRankMutateConfig extends PageRankConfig, MutateNodePropertyConfig {

private static PageRankMutateConfig of(CypherMapWrapper userInput, boolean checkDampingFactor) {
if (checkDampingFactor && userInput.containsKey("dampingFactor")) {
throw new IllegalArgumentException("Unexpected configuration key: dampingFactor");
}

static PageRankMutateConfig of(CypherMapWrapper userInput) {
return new PageRankMutateConfigImpl(userInput);
}

static PageRankMutateConfig configWithDampingFactor(CypherMapWrapper userInput) {
return of(userInput, false);
}

static PageRankMutateConfig configWithoutDampingFactor(CypherMapWrapper userInput) {
return of(userInput, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,7 @@
@Configuration
public interface PageRankStatsConfig extends PageRankConfig {

private static PageRankStatsConfig of(CypherMapWrapper userInput, boolean checkDampingFactor) {
if (checkDampingFactor && userInput.containsKey("dampingFactor")) {
throw new IllegalArgumentException("Unexpected configuration key: dampingFactor");
}
public static PageRankStatsConfig of(CypherMapWrapper userInput) {
return new PageRankStatsConfigImpl(userInput);
}

static PageRankStatsConfig configWithDampingFactor(CypherMapWrapper userInput) {
return of(userInput, false);
}

static PageRankStatsConfig configWithoutDampingFactor(CypherMapWrapper userInput) {
return of(userInput, true);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,8 @@
@Configuration
public interface PageRankStreamConfig extends PageRankConfig {

private static PageRankStreamConfig of(CypherMapWrapper userInput, boolean checkDampingFactor) {
if (checkDampingFactor && userInput.containsKey("dampingFactor")) {
throw new IllegalArgumentException("Unexpected configuration key: dampingFactor");
}

static PageRankStreamConfig of(CypherMapWrapper userInput) {
return new PageRankStreamConfigImpl(userInput);
}

static PageRankStreamConfig configWithDampingFactor(CypherMapWrapper userInput) {
return of(userInput, false);
}

static PageRankStreamConfig configWithoutDampingFactor(CypherMapWrapper userInput) {
return of(userInput, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,7 @@
@Configuration
public interface PageRankWriteConfig extends PageRankConfig, WritePropertyConfig {

private static PageRankWriteConfig of(CypherMapWrapper userInput, boolean checkDampingFactor) {
if (checkDampingFactor && userInput.containsKey("dampingFactor")) {
throw new IllegalArgumentException("Unexpected configuration key: dampingFactor");
}
public static PageRankWriteConfig of(CypherMapWrapper userInput) {
return new PageRankWriteConfigImpl(userInput);
}

static PageRankWriteConfig configWithDampingFactor(CypherMapWrapper userInput) {
return of(userInput, false);
}

static PageRankWriteConfig configWithoutDampingFactor(CypherMapWrapper userInput) {
return of(userInput, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import org.neo4j.gds.influenceMaximization.CELFMemoryEstimateDefinition;
import org.neo4j.gds.influenceMaximization.InfluenceMaximizationBaseConfig;
import org.neo4j.gds.mem.MemoryEstimation;
import org.neo4j.gds.pagerank.PageRankConfig;
import org.neo4j.gds.pagerank.PageRankMemoryEstimateDefinition;
import org.neo4j.gds.pagerank.RankConfig;

public class CentralityAlgorithmsEstimationModeBusinessFacade {
private final AlgorithmEstimationTemplate algorithmEstimationTemplate;
Expand Down Expand Up @@ -136,7 +136,7 @@ public MemoryEstimation pageRank() {
return new PageRankMemoryEstimateDefinition().memoryEstimation();
}

public MemoryEstimateResult pageRank(PageRankConfig configuration, Object graphNameOrConfiguration) {
public MemoryEstimateResult pageRank(RankConfig configuration, Object graphNameOrConfiguration) {
var memoryEstimation = pageRank();

return algorithmEstimationTemplate.estimate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import org.neo4j.gds.louvain.LouvainMutateConfig;
import org.neo4j.gds.ml.splitting.SplitRelationshipsMutateConfig;
import org.neo4j.gds.modularityoptimization.ModularityOptimizationMutateConfig;
import org.neo4j.gds.pagerank.ArticleRankMutateConfig;
import org.neo4j.gds.pagerank.EigenvectorMutateConfig;
import org.neo4j.gds.pagerank.PageRankMutateConfig;
import org.neo4j.gds.paths.astar.config.ShortestPathAStarMutateConfig;
import org.neo4j.gds.paths.bellmanford.AllShortestPathsBellmanFordMutateConfig;
Expand Down Expand Up @@ -80,7 +82,7 @@ public Function<CypherMapWrapper, AlgoBaseConfig> lookup(Algorithm algorithm) {
return switch (algorithm) {
case AllShortestPaths -> null;
case ApproximateMaximumKCut -> ApproxMaxKCutMutateConfig::of;
case ArticleRank -> PageRankMutateConfig::configWithDampingFactor;
case ArticleRank -> ArticleRankMutateConfig::of;
case ArticulationPoints -> ArticulationPointsMutateConfig::of;
case AStar -> ShortestPathAStarMutateConfig::of;
case BellmanFord -> AllShortestPathsBellmanFordMutateConfig::of;
Expand All @@ -96,7 +98,7 @@ public Function<CypherMapWrapper, AlgoBaseConfig> lookup(Algorithm algorithm) {
case DeltaStepping -> AllShortestPathsDeltaMutateConfig::of;
case DFS -> DfsMutateConfig::of;
case Dijkstra -> ShortestPathDijkstraMutateConfig::of;
case EigenVector -> PageRankMutateConfig::configWithoutDampingFactor;
case EigenVector -> EigenvectorMutateConfig::of;
case FastRP -> FastRPMutateConfig::of;
case FilteredKNN -> FilteredKnnMutateConfig::of;
case FilteredNodeSimilarity -> FilteredNodeSimilarityMutateConfig::of;
Expand All @@ -120,7 +122,7 @@ public Function<CypherMapWrapper, AlgoBaseConfig> lookup(Algorithm algorithm) {
case ModularityOptimization -> ModularityOptimizationMutateConfig::of;
case NodeSimilarity -> NodeSimilarityMutateConfig::of;
case Node2Vec -> Node2VecMutateConfig::of;
case PageRank -> PageRankMutateConfig::configWithDampingFactor;
case PageRank -> PageRankMutateConfig::of;
case RandomWalk -> null;
case ScaleProperties -> ScalePropertiesMutateConfig::of;
case SCC -> SccMutateConfig::of;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public PageRankAlgorithmFactory<PageRankMutateConfig> algorithmFactory(Execution

@Override
public NewConfigFunction<PageRankMutateConfig> newConfigFunction() {
return (___, config) -> PageRankMutateConfig.configWithDampingFactor(config);
return (___, config) -> PageRankMutateConfig.of(config);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public PageRankAlgorithmFactory<PageRankStatsConfig> algorithmFactory(ExecutionC

@Override
public NewConfigFunction<PageRankStatsConfig> newConfigFunction() {
return (___, config) -> PageRankStatsConfig.configWithDampingFactor(config);
return (___, config) -> PageRankStatsConfig.of(config);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public PageRankAlgorithmFactory<PageRankStreamConfig> algorithmFactory(Execution

@Override
public NewConfigFunction<PageRankStreamConfig> newConfigFunction() {
return (___,config) -> PageRankStreamConfig.configWithDampingFactor(config);
return (___,config) -> PageRankStreamConfig.of(config);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public PageRankAlgorithmFactory<PageRankWriteConfig> algorithmFactory(ExecutionC

@Override
public NewConfigFunction<PageRankWriteConfig> newConfigFunction() {
return (___,config) -> PageRankWriteConfig.configWithDampingFactor(config);
return (___,config) -> PageRankWriteConfig.of(config);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public static CentralityProcedureFacade create(
estimationModeBusinessFacade,
procedureReturnColumns,
mutateModeBusinessFacade::pageRank,
PageRankMutateConfig::configWithDampingFactor
PageRankMutateConfig::of

);

Expand Down Expand Up @@ -297,7 +297,7 @@ public Stream<MemoryEstimateResult> articleRankStatsEstimate(
) {
var parsedConfiguration = configurationParser.parseConfiguration(
algorithmConfiguration,
PageRankStatsConfig::configWithDampingFactor
ArticleRankStatsConfig::of
);

return Stream.of(estimationModeBusinessFacade.pageRank(parsedConfiguration, graphNameOrConfiguration));
Expand All @@ -323,7 +323,7 @@ public Stream<MemoryEstimateResult> articleRankStreamEstimate(
) {
var parsedConfiguration = configurationParser.parseConfiguration(
algorithmConfiguration,
PageRankStreamConfig::configWithoutDampingFactor
ArticleRankStreamConfig::of
);

return Stream.of(estimationModeBusinessFacade.pageRank(parsedConfiguration, graphNameOrConfiguration));
Expand Down Expand Up @@ -354,7 +354,7 @@ public Stream<MemoryEstimateResult> articleRankWriteEstimate(
) {
var parsedConfiguration = configurationParser.parseConfiguration(
algorithmConfiguration,
PageRankWriteConfig::configWithoutDampingFactor
ArticleRankWriteConfig::of
);

return Stream.of(estimationModeBusinessFacade.pageRank(parsedConfiguration, graphNameOrConfiguration));
Expand Down Expand Up @@ -920,7 +920,7 @@ public Stream<MemoryEstimateResult> eigenvectorStatsEstimate(
) {
var parsedConfiguration = configurationParser.parseConfiguration(
algorithmConfiguration,
PageRankStatsConfig::configWithoutDampingFactor
EigenvectorStatsConfig::of
);

return Stream.of(estimationModeBusinessFacade.pageRank(parsedConfiguration, graphNameOrConfiguration));
Expand All @@ -947,7 +947,7 @@ public Stream<MemoryEstimateResult> eigenvectorStreamEstimate(
) {
var parsedConfiguration = configurationParser.parseConfiguration(
algorithmConfiguration,
PageRankStreamConfig::configWithoutDampingFactor
EigenvectorStreamConfig::of
);

return Stream.of(estimationModeBusinessFacade.pageRank(parsedConfiguration, graphNameOrConfiguration));
Expand Down Expand Up @@ -975,7 +975,7 @@ public Stream<MemoryEstimateResult> eigenvectorWriteEstimate(
) {
var parsedConfiguration = configurationParser.parseConfiguration(
algorithmConfiguration,
PageRankWriteConfig::configWithoutDampingFactor
EigenvectorWriteConfig::of
);

return Stream.of(estimationModeBusinessFacade.pageRank(parsedConfiguration, graphNameOrConfiguration));
Expand Down Expand Up @@ -1045,7 +1045,7 @@ public Stream<PageRankStatsResult> pageRankStats(String graphName, Map<String, O

var parsedConfiguration = configurationParser.parseConfiguration(
configuration,
PageRankStatsConfig::configWithDampingFactor
PageRankStatsConfig::of
);

return statsModeBusinessFacade.pageRank(
Expand All @@ -1061,7 +1061,7 @@ public Stream<MemoryEstimateResult> pageRankStatsEstimate(
) {
var parsedConfiguration = configurationParser.parseConfiguration(
algorithmConfiguration,
PageRankStatsConfig::configWithDampingFactor
PageRankStatsConfig::of
);

return Stream.of(estimationModeBusinessFacade.pageRank(parsedConfiguration, graphNameOrConfiguration));
Expand All @@ -1072,7 +1072,7 @@ public Stream<CentralityStreamResult> pageRankStream(String graphName, Map<Strin

var parsedConfiguration = configurationParser.parseConfiguration(
configuration,
PageRankStreamConfig::configWithDampingFactor
PageRankStreamConfig::of
);

return streamModeBusinessFacade.pageRank(
Expand All @@ -1088,7 +1088,7 @@ public Stream<MemoryEstimateResult> pageRankStreamEstimate(
) {
var parsedConfiguration = configurationParser.parseConfiguration(
algorithmConfiguration,
PageRankStreamConfig::configWithDampingFactor
PageRankStreamConfig::of
);

return Stream.of(estimationModeBusinessFacade.pageRank(parsedConfiguration, graphNameOrConfiguration));
Expand All @@ -1101,7 +1101,7 @@ public Stream<PageRankWriteResult> pageRankWrite(String graphName, Map<String, O

var parsedConfiguration = configurationParser.parseConfiguration(
configuration,
PageRankWriteConfig::configWithDampingFactor
PageRankWriteConfig::of
);

return writeModeBusinessFacade.pageRank(
Expand All @@ -1117,7 +1117,7 @@ public Stream<MemoryEstimateResult> pageRankWriteEstimate(
) {
var parsedConfiguration = configurationParser.parseConfiguration(
algorithmConfiguration,
PageRankWriteConfig::configWithDampingFactor
PageRankWriteConfig::of
);

return Stream.of(estimationModeBusinessFacade.pageRank(parsedConfiguration, graphNameOrConfiguration));
Expand Down

0 comments on commit 73b220f

Please sign in to comment.