From 4ea2f0e888370a7d82833ae3d14ec0cff881a661 Mon Sep 17 00:00:00 2001 From: Lasse Westh-Nielsen Date: Fri, 12 Jul 2024 17:18:54 +0200 Subject: [PATCH] migrate collapsepath --- ...ityAlgorithmsMutateModeBusinessFacade.java | 16 ++-- ...lityAlgorithmsStatsModeBusinessFacade.java | 18 ++-- ...ityAlgorithmsStreamModeBusinessFacade.java | 18 ++-- ...lityAlgorithmsWriteModeBusinessFacade.java | 16 ++-- ...ityAlgorithmsMutateModeBusinessFacade.java | 24 ++--- ...nityAlgorithmsStatsModeBusinessFacade.java | 26 +++--- ...ityAlgorithmsStreamModeBusinessFacade.java | 32 +++---- ...nityAlgorithmsWriteModeBusinessFacade.java | 24 ++--- .../machinery/AlgorithmComputation.java | 13 ++- .../DefaultAlgorithmProcessingTemplate.java | 13 +-- .../algorithms/metadata/Algorithm.java | 1 + .../metadata/LabelForProgressTracking.java | 2 + ...efaultAlgorithmProcessingTemplateTest.java | 7 +- .../miscellaneous/CollapsePathMutateStep.java | 42 +++++++++ .../MiscellaneousAlgorithms.java | 47 +++++++++- ...licationsEstimationModeBusinessFacade.java | 5 ++ ...sApplicationsMutateModeBusinessFacade.java | 23 ++++- ...usApplicationsStatsModeBusinessFacade.java | 2 +- ...sApplicationsStreamModeBusinessFacade.java | 2 +- ...usApplicationsWriteModeBusinessFacade.java | 2 +- .../algorithms/node-embeddings/build.gradle | 2 +- .../GraphSageAlgorithmProcessing.java | 2 +- .../Node2VecAlgorithmProcessing.java | 2 +- ...ingAlgorithmsMutateModeBusinessFacade.java | 4 +- ...dingAlgorithmsStatsModeBusinessFacade.java | 4 +- ...ingAlgorithmsStreamModeBusinessFacade.java | 6 +- ...dingAlgorithmsTrainModeBusinessFacade.java | 4 +- ...dingAlgorithmsWriteModeBusinessFacade.java | 2 +- ...ingAlgorithmsMutateModeBusinessFacade.java | 20 ++--- ...dingAlgorithmsStatsModeBusinessFacade.java | 14 +-- ...ingAlgorithmsStreamModeBusinessFacade.java | 30 +++---- ...dingAlgorithmsWriteModeBusinessFacade.java | 20 ++--- ...ityAlgorithmsMutateModeBusinessFacade.java | 8 +- ...rityAlgorithmsStatsModeBusinessFacade.java | 10 +-- ...ityAlgorithmsStreamModeBusinessFacade.java | 10 +-- ...rityAlgorithmsWriteModeBusinessFacade.java | 10 +-- .../ConfigurationParsersForMutateMode.java | 2 + .../pipeline/MutateModeAlgorithmLibrary.java | 1 + .../neo4j/gds/ml/pipeline/StubbyHolder.java | 2 + .../ml/pipeline/stubs/CollapsePathStub.java | 31 +++++++ .../gds/walking/CollapsePathMutateProc.java | 28 +++--- .../gds/walking/CollapsePathMutateSpec.java | 9 +- .../CollapsePathMutateResult.java | 26 ++++-- .../MiscellaneousProcedureFacade.java | 10 +++ .../stubs/CollapsePathMutateStub.java | 87 +++++++++++++++++++ ...ollapsePathResultBuilderForMutateMode.java | 54 ++++++++++++ 46 files changed, 529 insertions(+), 202 deletions(-) create mode 100644 applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/CollapsePathMutateStep.java create mode 100644 pipeline/src/main/java/org/neo4j/gds/ml/pipeline/stubs/CollapsePathStub.java rename proc/misc/src/main/java/org/neo4j/gds/walking/MutateResult.java => procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/CollapsePathMutateResult.java (68%) create mode 100644 procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/stubs/CollapsePathMutateStub.java create mode 100644 procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/stubs/CollapsePathResultBuilderForMutateMode.java diff --git a/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsMutateModeBusinessFacade.java b/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsMutateModeBusinessFacade.java index b97f489b46..cd049755f5 100644 --- a/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsMutateModeBusinessFacade.java +++ b/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsMutateModeBusinessFacade.java @@ -76,7 +76,7 @@ public RESULT articleRank( configuration, ArticleRank, estimation::pageRank, - graph -> algorithms.articleRank(graph, configuration), + (graph, __) -> algorithms.articleRank(graph, configuration), mutateStep, resultBuilder ); @@ -94,7 +94,7 @@ public RESULT betweennessCentrality( configuration, BetweennessCentrality, () -> estimation.betweennessCentrality(configuration), - graph -> algorithms.betweennessCentrality(graph, configuration), + (graph, __) -> algorithms.betweennessCentrality(graph, configuration), mutateStep, resultBuilder ); @@ -112,7 +112,7 @@ public RESULT celf( configuration, CELF, () -> estimation.celf(configuration), - graph -> algorithms.celf(graph, configuration), + (graph, __) -> algorithms.celf(graph, configuration), mutateStep, resultBuilder ); @@ -130,7 +130,7 @@ public RESULT closenessCentrality( configuration, ClosenessCentrality, () -> estimation.closenessCentrality(configuration), - graph -> algorithms.closenessCentrality(graph, configuration), + (graph, __) -> algorithms.closenessCentrality(graph, configuration), mutateStep, resultBuilder ); @@ -148,7 +148,7 @@ public RESULT degreeCentrality( configuration, DegreeCentrality, () -> estimation.degreeCentrality(configuration), - graph -> algorithms.degreeCentrality(graph, configuration), + (graph, __) -> algorithms.degreeCentrality(graph, configuration), mutateStep, resultBuilder ); @@ -166,7 +166,7 @@ public RESULT eigenVector( configuration, EigenVector, estimation::pageRank, - graph -> algorithms.eigenVector(graph, configuration), + (graph, __) -> algorithms.eigenVector(graph, configuration), mutateStep, resultBuilder ); @@ -184,7 +184,7 @@ public RESULT harmonicCentrality( configuration, HarmonicCentrality, estimation::harmonicCentrality, - graph -> algorithms.harmonicCentrality(graph, configuration), + (graph, __) -> algorithms.harmonicCentrality(graph, configuration), mutateStep, resultBuilder ); @@ -202,7 +202,7 @@ public RESULT pageRank( configuration, PageRank, estimation::pageRank, - graph -> algorithms.pageRank(graph, configuration), + (graph, __) -> algorithms.pageRank(graph, configuration), mutateStep, resultBuilder ); diff --git a/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsStatsModeBusinessFacade.java b/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsStatsModeBusinessFacade.java index 1d18603f5e..ca0a9f22bc 100644 --- a/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsStatsModeBusinessFacade.java +++ b/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsStatsModeBusinessFacade.java @@ -46,7 +46,7 @@ public class CentralityAlgorithmsStatsModeBusinessFacade { private final CentralityAlgorithms centralityAlgorithms; private final AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience; - public CentralityAlgorithmsStatsModeBusinessFacade( + CentralityAlgorithmsStatsModeBusinessFacade( CentralityAlgorithmsEstimationModeBusinessFacade estimationFacade, CentralityAlgorithms centralityAlgorithms, AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience @@ -66,7 +66,7 @@ public RESULT articleRank( configuration, ArticleRank, estimationFacade::pageRank, - graph -> centralityAlgorithms.articleRank(graph, configuration), + (graph, __) -> centralityAlgorithms.articleRank(graph, configuration), resultBuilder ); } @@ -81,7 +81,7 @@ public RESULT betweennessCentrality( configuration, BetweennessCentrality, () -> estimationFacade.betweennessCentrality(configuration), - graph -> centralityAlgorithms.betweennessCentrality(graph, configuration), + (graph, __) -> centralityAlgorithms.betweennessCentrality(graph, configuration), resultBuilder ); } @@ -96,7 +96,7 @@ public RESULT celf( configuration, CELF, () -> estimationFacade.celf(configuration), - graph -> centralityAlgorithms.celf(graph, configuration), + (graph, __) -> centralityAlgorithms.celf(graph, configuration), resultBuilder ); } @@ -111,7 +111,7 @@ public RESULT closenessCentrality( configuration, ClosenessCentrality, () -> estimationFacade.closenessCentrality(configuration), - graph -> centralityAlgorithms.closenessCentrality(graph, configuration), + (graph, __) -> centralityAlgorithms.closenessCentrality(graph, configuration), resultBuilder ); } @@ -126,7 +126,7 @@ public RESULT degreeCentrality( configuration, DegreeCentrality, () -> estimationFacade.degreeCentrality(configuration), - graph -> centralityAlgorithms.degreeCentrality(graph, configuration), + (graph, __) -> centralityAlgorithms.degreeCentrality(graph, configuration), resultBuilder ); } @@ -141,7 +141,7 @@ public RESULT eigenVector( configuration, EigenVector, estimationFacade::pageRank, - graph -> centralityAlgorithms.eigenVector(graph, configuration), + (graph, __) -> centralityAlgorithms.eigenVector(graph, configuration), resultBuilder ); } @@ -156,7 +156,7 @@ public RESULT harmonicCentrality( configuration, HarmonicCentrality, estimationFacade::harmonicCentrality, - graph -> centralityAlgorithms.harmonicCentrality(graph, configuration), + (graph, __) -> centralityAlgorithms.harmonicCentrality(graph, configuration), resultBuilder ); } @@ -171,7 +171,7 @@ public RESULT pageRank( configuration, PageRank, estimationFacade::pageRank, - graph -> centralityAlgorithms.pageRank(graph, configuration), + (graph, __) -> centralityAlgorithms.pageRank(graph, configuration), resultBuilder ); } diff --git a/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsStreamModeBusinessFacade.java b/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsStreamModeBusinessFacade.java index 75f4a5a959..8dc4eed08e 100644 --- a/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsStreamModeBusinessFacade.java +++ b/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsStreamModeBusinessFacade.java @@ -47,7 +47,7 @@ public class CentralityAlgorithmsStreamModeBusinessFacade { private final CentralityAlgorithms centralityAlgorithms; private final AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience; - public CentralityAlgorithmsStreamModeBusinessFacade( + CentralityAlgorithmsStreamModeBusinessFacade( CentralityAlgorithmsEstimationModeBusinessFacade estimationFacade, CentralityAlgorithms centralityAlgorithms, AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience @@ -67,7 +67,7 @@ public RESULT articleRank( configuration, ArticleRank, estimationFacade::pageRank, - graph -> centralityAlgorithms.articleRank(graph, configuration), + (graph, __) -> centralityAlgorithms.articleRank(graph, configuration), resultBuilder ); } @@ -82,7 +82,7 @@ public RESULT betweennessCentrality( configuration, BetweennessCentrality, () -> estimationFacade.betweennessCentrality(configuration), - graph -> centralityAlgorithms.betweennessCentrality(graph, configuration), + (graph, __) -> centralityAlgorithms.betweennessCentrality(graph, configuration), resultBuilder ); } @@ -97,7 +97,7 @@ public RESULT celf( configuration, CELF, () -> estimationFacade.celf(configuration), - graph -> centralityAlgorithms.celf(graph, configuration), + (graph, __) -> centralityAlgorithms.celf(graph, configuration), resultBuilder ); } @@ -112,7 +112,7 @@ public RESULT closenessCentrality( configuration, ClosenessCentrality, () -> estimationFacade.closenessCentrality(configuration), - graph -> centralityAlgorithms.closenessCentrality(graph, configuration), + (graph, __) -> centralityAlgorithms.closenessCentrality(graph, configuration), resultBuilder ); } @@ -127,7 +127,7 @@ public RESULT degreeCentrality( configuration, DegreeCentrality, () -> estimationFacade.degreeCentrality(configuration), - graph -> centralityAlgorithms.degreeCentrality(graph, configuration), + (graph, __) -> centralityAlgorithms.degreeCentrality(graph, configuration), resultBuilder ); } @@ -142,7 +142,7 @@ public RESULT eigenvector( configuration, EigenVector, estimationFacade::pageRank, - graph -> centralityAlgorithms.eigenVector(graph, configuration), + (graph, __) -> centralityAlgorithms.eigenVector(graph, configuration), resultBuilder ); } @@ -157,7 +157,7 @@ public RESULT harmonicCentrality( configuration, HarmonicCentrality, estimationFacade::harmonicCentrality, - graph -> centralityAlgorithms.harmonicCentrality(graph, configuration), + (graph, __) -> centralityAlgorithms.harmonicCentrality(graph, configuration), resultBuilder ); } @@ -172,7 +172,7 @@ public RESULT pageRank( configuration, PageRank, estimationFacade::pageRank, - graph -> centralityAlgorithms.pageRank(graph, configuration), + (graph, __) -> centralityAlgorithms.pageRank(graph, configuration), resultBuilder ); } diff --git a/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsWriteModeBusinessFacade.java b/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsWriteModeBusinessFacade.java index 805f6624bc..9da6034ba0 100644 --- a/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsWriteModeBusinessFacade.java +++ b/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithmsWriteModeBusinessFacade.java @@ -95,7 +95,7 @@ public RESULT articleRank( configuration, ArticleRank, estimationFacade::pageRank, - graph -> centralityAlgorithms.articleRank(graph, configuration), + (graph, __) -> centralityAlgorithms.articleRank(graph, configuration), writeStep, resultBuilder ); @@ -113,7 +113,7 @@ public RESULT betweennessCentrality( configuration, BetweennessCentrality, () -> estimationFacade.betweennessCentrality(configuration), - graph -> centralityAlgorithms.betweennessCentrality(graph, configuration), + (graph, __) -> centralityAlgorithms.betweennessCentrality(graph, configuration), writeStep, resultBuilder ); @@ -131,7 +131,7 @@ public RESULT c configuration, CELF, () -> estimationFacade.celf(configuration), - graph -> centralityAlgorithms.celf(graph, configuration), + (graph, __) -> centralityAlgorithms.celf(graph, configuration), writeStep, resultBuilder ); @@ -149,7 +149,7 @@ public RESULT closenessCentrality( configuration, ClosenessCentrality, () -> estimationFacade.closenessCentrality(configuration), - graph -> centralityAlgorithms.closenessCentrality(graph, configuration), + (graph, __) -> centralityAlgorithms.closenessCentrality(graph, configuration), writeStep, resultBuilder ); @@ -167,7 +167,7 @@ public RESULT degreeCentrality( configuration, DegreeCentrality, () -> estimationFacade.degreeCentrality(configuration), - graph -> centralityAlgorithms.degreeCentrality(graph, configuration), + (graph, __) -> centralityAlgorithms.degreeCentrality(graph, configuration), writeStep, resultBuilder ); @@ -185,7 +185,7 @@ public RESULT eigenvector( configuration, EigenVector, estimationFacade::pageRank, - graph -> centralityAlgorithms.eigenVector(graph, configuration), + (graph, __) -> centralityAlgorithms.eigenVector(graph, configuration), writeStep, resultBuilder ); @@ -203,7 +203,7 @@ public RESULT harm configuration, HarmonicCentrality, estimationFacade::harmonicCentrality, - graph -> centralityAlgorithms.harmonicCentrality(graph, configuration), + (graph, __) -> centralityAlgorithms.harmonicCentrality(graph, configuration), writeStep, resultBuilder ); @@ -221,7 +221,7 @@ public RESULT pageRank( configuration, PageRank, estimationFacade::pageRank, - graph -> centralityAlgorithms.pageRank(graph, configuration), + (graph, __) -> centralityAlgorithms.pageRank(graph, configuration), writeStep, resultBuilder ); diff --git a/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsMutateModeBusinessFacade.java b/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsMutateModeBusinessFacade.java index 453cd4588c..468d2bd627 100644 --- a/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsMutateModeBusinessFacade.java +++ b/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsMutateModeBusinessFacade.java @@ -94,7 +94,7 @@ public RESULT approximateMaximumKCut( configuration, ApproximateMaximumKCut, () -> estimation.approximateMaximumKCut(configuration), - graph -> algorithms.approximateMaximumKCut(graph, configuration), + (graph, __) -> algorithms.approximateMaximumKCut(graph, configuration), mutateStep, resultBuilder ); @@ -112,7 +112,7 @@ public RESULT k1Coloring( configuration, K1Coloring, estimation::k1Coloring, - graph -> algorithms.k1Coloring(graph, configuration), + (graph, __) -> algorithms.k1Coloring(graph, configuration), mutateStep, resultBuilder ); @@ -130,7 +130,7 @@ public RESULT kCore( configuration, KCore, estimation::kCore, - graph -> algorithms.kCore(graph, configuration), + (graph, __) -> algorithms.kCore(graph, configuration), mutateStep, resultBuilder ); @@ -148,7 +148,7 @@ public RESULT kMeans( configuration, KMeans, () -> estimation.kMeans(configuration), - graph -> algorithms.kMeans(graph, configuration), + (graph, __) -> algorithms.kMeans(graph, configuration), mutateStep, resultBuilder ); @@ -166,7 +166,7 @@ public RESULT labelPropagation( configuration, LabelPropagation, estimation::labelPropagation, - graph -> algorithms.labelPropagation(graph, configuration), + (graph, __) -> algorithms.labelPropagation(graph, configuration), mutateStep, resultBuilder ); @@ -184,7 +184,7 @@ public RESULT lcc( configuration, LCC, () -> estimation.lcc(configuration), - graph -> algorithms.lcc(graph, configuration), + (graph, __) -> algorithms.lcc(graph, configuration), mutateStep, resultBuilder ); @@ -202,7 +202,7 @@ public RESULT leiden( configuration, Leiden, () -> estimation.leiden(configuration), - graph -> algorithms.leiden(graph, configuration), + (graph, __) -> algorithms.leiden(graph, configuration), mutateStep, resultBuilder ); @@ -220,7 +220,7 @@ public RESULT louvain( configuration, Louvain, () -> estimation.louvain(configuration), - graph -> algorithms.louvain(graph, configuration), + (graph, __) -> algorithms.louvain(graph, configuration), mutateStep, resultBuilder ); @@ -238,7 +238,7 @@ public RESULT modularityOptimization( configuration, ModularityOptimization, estimation::modularityOptimization, - graph -> algorithms.modularityOptimization(graph, configuration), + (graph, __) -> algorithms.modularityOptimization(graph, configuration), mutateStep, resultBuilder ); @@ -256,7 +256,7 @@ public RESULT scc( configuration, SCC, estimation::scc, - graph -> algorithms.scc(graph, configuration), + (graph, __) -> algorithms.scc(graph, configuration), mutateStep, resultBuilder ); @@ -274,7 +274,7 @@ public RESULT triangleCount( configuration, TriangleCount, estimation::triangleCount, - graph -> algorithms.triangleCount(graph, configuration), + (graph, __) -> algorithms.triangleCount(graph, configuration), mutateStep, resultBuilder ); @@ -292,7 +292,7 @@ public RESULT wcc( configuration, WCC, () -> estimation.wcc(configuration), - graph -> algorithms.wcc(graph, configuration), + (graph, __) -> algorithms.wcc(graph, configuration), mutateStep, resultBuilder ); diff --git a/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsStatsModeBusinessFacade.java b/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsStatsModeBusinessFacade.java index 4c0caf50e1..039df55eba 100644 --- a/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsStatsModeBusinessFacade.java +++ b/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsStatsModeBusinessFacade.java @@ -65,7 +65,7 @@ public class CommunityAlgorithmsStatsModeBusinessFacade { private final CommunityAlgorithms communityAlgorithms; private final AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience; - public CommunityAlgorithmsStatsModeBusinessFacade( + CommunityAlgorithmsStatsModeBusinessFacade( CommunityAlgorithmsEstimationModeBusinessFacade estimationFacade, CommunityAlgorithms communityAlgorithms, AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience @@ -85,7 +85,7 @@ public RESULT k1Coloring( configuration, K1Coloring, estimationFacade::k1Coloring, - graph -> communityAlgorithms.k1Coloring(graph, configuration), + (graph, __) -> communityAlgorithms.k1Coloring(graph, configuration), resultBuilder ); } @@ -100,7 +100,7 @@ public RESULT kCore( configuration, KCore, estimationFacade::kCore, - graph -> communityAlgorithms.kCore(graph, configuration), + (graph, __) -> communityAlgorithms.kCore(graph, configuration), resultBuilder ); } @@ -115,7 +115,7 @@ public RESULT kMeans( configuration, KMeans, () -> estimationFacade.kMeans(configuration), - graph -> communityAlgorithms.kMeans(graph, configuration), + (graph, __) -> communityAlgorithms.kMeans(graph, configuration), resultBuilder ); } @@ -130,7 +130,7 @@ public RESULT labelPropagation( configuration, LabelPropagation, estimationFacade::labelPropagation, - graph -> communityAlgorithms.labelPropagation(graph, configuration), + (graph, __) -> communityAlgorithms.labelPropagation(graph, configuration), resultBuilder ); } @@ -145,7 +145,7 @@ public RESULT lcc( configuration, LCC, () -> estimationFacade.lcc(configuration), - graph -> communityAlgorithms.lcc(graph, configuration), + (graph, __) -> communityAlgorithms.lcc(graph, configuration), resultBuilder ); } @@ -160,7 +160,7 @@ public RESULT leiden( configuration, Leiden, () -> estimationFacade.leiden(configuration), - graph -> communityAlgorithms.leiden(graph, configuration), + (graph, __) -> communityAlgorithms.leiden(graph, configuration), resultBuilder ); } @@ -175,7 +175,7 @@ public RESULT louvain( configuration, Louvain, () -> estimationFacade.louvain(configuration), - graph -> communityAlgorithms.louvain(graph, configuration), + (graph, __) -> communityAlgorithms.louvain(graph, configuration), resultBuilder ); } @@ -190,7 +190,7 @@ public RESULT modularity( configuration, Modularity, estimationFacade::modularity, - graph -> communityAlgorithms.modularity(graph, configuration), + (graph, __) -> communityAlgorithms.modularity(graph, configuration), resultBuilder ); } @@ -205,7 +205,7 @@ public RESULT modularityOptimization( configuration, ModularityOptimization, estimationFacade::modularityOptimization, - graph -> communityAlgorithms.modularityOptimization(graph, configuration), + (graph, __) -> communityAlgorithms.modularityOptimization(graph, configuration), resultBuilder ); } @@ -220,7 +220,7 @@ public RESULT scc( configuration, SCC, estimationFacade::scc, - graph -> communityAlgorithms.scc(graph, configuration), + (graph, __) -> communityAlgorithms.scc(graph, configuration), resultBuilder ); } @@ -235,7 +235,7 @@ public RESULT triangleCount( configuration, TriangleCount, estimationFacade::triangleCount, - graph -> communityAlgorithms.triangleCount(graph, configuration), + (graph, __) -> communityAlgorithms.triangleCount(graph, configuration), resultBuilder ); } @@ -250,7 +250,7 @@ public RESULT wcc( configuration, WCC, () -> estimationFacade.wcc(configuration), - graph -> communityAlgorithms.wcc(graph, configuration), + (graph, __) -> communityAlgorithms.wcc(graph, configuration), resultBuilder ); } diff --git a/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsStreamModeBusinessFacade.java b/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsStreamModeBusinessFacade.java index 06e5c13d66..fe1c3e7ead 100644 --- a/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsStreamModeBusinessFacade.java +++ b/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsStreamModeBusinessFacade.java @@ -76,7 +76,7 @@ public class CommunityAlgorithmsStreamModeBusinessFacade { private final CommunityAlgorithms algorithms; private final AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience; - public CommunityAlgorithmsStreamModeBusinessFacade( + CommunityAlgorithmsStreamModeBusinessFacade( CommunityAlgorithmsEstimationModeBusinessFacade estimationFacade, CommunityAlgorithms algorithms, AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience @@ -96,7 +96,7 @@ public RESULT approximateMaximumKCut( configuration, ApproximateMaximumKCut, () -> estimationFacade.approximateMaximumKCut(configuration), - graph -> algorithms.approximateMaximumKCut(graph, configuration), + (graph, __) -> algorithms.approximateMaximumKCut(graph, configuration), resultBuilder ); } @@ -111,7 +111,7 @@ public RESULT conductance( configuration, Conductance, estimationFacade::conductance, - graph -> algorithms.conductance(graph, configuration), + (graph, __) -> algorithms.conductance(graph, configuration), resultBuilder ); } @@ -126,7 +126,7 @@ public RESULT k1Coloring( configuration, K1Coloring, estimationFacade::k1Coloring, - graph -> algorithms.k1Coloring(graph, configuration), + (graph, __) -> algorithms.k1Coloring(graph, configuration), resultBuilder ); } @@ -141,7 +141,7 @@ public RESULT kCore( configuration, KCore, estimationFacade::kCore, - graph -> algorithms.kCore(graph, configuration), + (graph, __) -> algorithms.kCore(graph, configuration), resultBuilder ); } @@ -156,7 +156,7 @@ public RESULT kMeans( configuration, KMeans, () -> estimationFacade.kMeans(configuration), - graph -> algorithms.kMeans(graph, configuration), + (graph, __) -> algorithms.kMeans(graph, configuration), resultBuilder ); } @@ -171,7 +171,7 @@ public RESULT labelPropagation( configuration, LabelPropagation, estimationFacade::labelPropagation, - graph -> algorithms.labelPropagation(graph, configuration), + (graph, __) -> algorithms.labelPropagation(graph, configuration), resultBuilder ); } @@ -186,7 +186,7 @@ public RESULT lcc( configuration, LCC, () -> estimationFacade.lcc(configuration), - graph -> algorithms.lcc(graph, configuration), + (graph, __) -> algorithms.lcc(graph, configuration), resultBuilder ); } @@ -201,7 +201,7 @@ public RESULT leiden( configuration, Leiden, () -> estimationFacade.leiden(configuration), - graph -> algorithms.leiden(graph, configuration), + (graph, __) -> algorithms.leiden(graph, configuration), resultBuilder ); } @@ -216,7 +216,7 @@ public RESULT louvain( configuration, Louvain, () -> estimationFacade.louvain(configuration), - graph -> algorithms.louvain(graph, configuration), + (graph, __) -> algorithms.louvain(graph, configuration), resultBuilder ); } @@ -231,7 +231,7 @@ public RESULT modularity( configuration, Modularity, estimationFacade::modularity, - graph -> algorithms.modularity(graph, configuration), + (graph, __) -> algorithms.modularity(graph, configuration), resultBuilder ); } @@ -246,7 +246,7 @@ public RESULT modularityOptimization( configuration, ModularityOptimization, estimationFacade::modularityOptimization, - graph -> algorithms.modularityOptimization(graph, configuration), + (graph, __) -> algorithms.modularityOptimization(graph, configuration), resultBuilder ); } @@ -261,7 +261,7 @@ public RESULT scc( configuration, SCC, estimationFacade::scc, - graph -> algorithms.scc(graph, configuration), + (graph, __) -> algorithms.scc(graph, configuration), resultBuilder ); } @@ -276,7 +276,7 @@ public RESULT triangleCount( configuration, TriangleCount, estimationFacade::triangleCount, - graph -> algorithms.triangleCount(graph, configuration), + (graph, __) -> algorithms.triangleCount(graph, configuration), resultBuilder ); } @@ -291,7 +291,7 @@ public RESULT triangles( configuration, Triangles, estimationFacade::triangles, - graph -> algorithms.triangles(graph, configuration), + (graph, __) -> algorithms.triangles(graph, configuration), resultBuilder ); } @@ -306,7 +306,7 @@ public RESULT wcc( configuration, WCC, () -> estimationFacade.wcc(configuration), - graph -> algorithms.wcc(graph, configuration), + (graph, __) -> algorithms.wcc(graph, configuration), resultBuilder ); } diff --git a/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsWriteModeBusinessFacade.java b/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsWriteModeBusinessFacade.java index 72123a7a40..5b9fcceb6f 100644 --- a/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsWriteModeBusinessFacade.java +++ b/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithmsWriteModeBusinessFacade.java @@ -113,7 +113,7 @@ public RESULT k1Coloring( configuration, K1Coloring, estimationFacade::k1Coloring, - graph -> algorithms.k1Coloring(graph, configuration), + (graph, __) -> algorithms.k1Coloring(graph, configuration), writeStep, resultBuilder ); @@ -131,7 +131,7 @@ public RESULT kCore( configuration, KCore, estimationFacade::kCore, - graph -> algorithms.kCore(graph, configuration), + (graph, __) -> algorithms.kCore(graph, configuration), writeStep, resultBuilder ); @@ -149,7 +149,7 @@ public RESULT kMeans( configuration, KMeans, () -> estimationFacade.kMeans(configuration), - graph -> algorithms.kMeans(graph, configuration), + (graph, __) -> algorithms.kMeans(graph, configuration), writeStep, resultBuilder ); @@ -167,7 +167,7 @@ public RESULT labelPropagation( configuration, LabelPropagation, estimationFacade::labelPropagation, - graph -> algorithms.labelPropagation(graph, configuration), + (graph, __) -> algorithms.labelPropagation(graph, configuration), writeStep, resultBuilder ); @@ -185,7 +185,7 @@ public RESULT lcc( configuration, LCC, () -> estimationFacade.lcc(configuration), - graph -> algorithms.lcc(graph, configuration), + (graph, __) -> algorithms.lcc(graph, configuration), writeStep, resultBuilder ); @@ -203,7 +203,7 @@ public RESULT leiden( configuration, Leiden, () -> estimationFacade.leiden(configuration), - graph -> algorithms.leiden(graph, configuration), + (graph, __) -> algorithms.leiden(graph, configuration), writeStep, resultBuilder ); @@ -221,7 +221,7 @@ public RESULT louvain( configuration, Louvain, () -> estimationFacade.louvain(configuration), - graph -> algorithms.louvain(graph, configuration), + (graph, __) -> algorithms.louvain(graph, configuration), writeStep, resultBuilder ); @@ -239,7 +239,7 @@ public RESULT modularityOptimization( configuration, ModularityOptimization, estimationFacade::modularityOptimization, - graph -> algorithms.modularityOptimization(graph, configuration), + (graph, __) -> algorithms.modularityOptimization(graph, configuration), writeStep, resultBuilder ); @@ -257,7 +257,7 @@ public RESULT scc( configuration, SCC, estimationFacade::scc, - graph -> algorithms.scc(graph, configuration), + (graph, __) -> algorithms.scc(graph, configuration), writeStep, resultBuilder ); @@ -275,7 +275,7 @@ public RESULT sccAlpha( configuration, SCC, estimationFacade::scc, - graph -> algorithms.scc(graph, configuration), + (graph, __) -> algorithms.scc(graph, configuration), writeStep, resultBuilder ); @@ -293,7 +293,7 @@ public RESULT triangleCount( configuration, TriangleCount, estimationFacade::triangleCount, - graph -> algorithms.triangleCount(graph, configuration), + (graph, __) -> algorithms.triangleCount(graph, configuration), writeStep, resultBuilder ); @@ -311,7 +311,7 @@ public RESULT wcc( configuration, WCC, () -> estimationFacade.wcc(configuration), - graph -> algorithms.wcc(graph, configuration), + (graph, __) -> algorithms.wcc(graph, configuration), writeStep, resultBuilder ); diff --git a/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/AlgorithmComputation.java b/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/AlgorithmComputation.java index d7c74e909c..d9b8fecc5d 100644 --- a/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/AlgorithmComputation.java +++ b/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/AlgorithmComputation.java @@ -20,7 +20,18 @@ package org.neo4j.gds.applications.algorithms.machinery; import org.neo4j.gds.api.Graph; +import org.neo4j.gds.api.GraphStore; +/** + * The framework hook for all the algorithms computations. + * (Other things you can inject in constructor of course) + */ public interface AlgorithmComputation { - RESULT compute(Graph graph); + /** + * The lowest common denominator of things algorithm computations need + * + * @param graph all except CollapsePath need this + * @param graphStore only CollapsePath needs this + */ + RESULT compute(Graph graph, GraphStore graphStore); } diff --git a/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/DefaultAlgorithmProcessingTemplate.java b/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/DefaultAlgorithmProcessingTemplate.java index 9b17bb957c..70a9d7d8fb 100644 --- a/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/DefaultAlgorithmProcessingTemplate.java +++ b/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/machinery/DefaultAlgorithmProcessingTemplate.java @@ -101,7 +101,8 @@ public RESULT_FROM_ALGORITHM computeWithTiming( AlgorithmProcessingTimingsBuilder timingsBuilder, LabelForProgressTracking label, AlgorithmComputation algorithmComputation, - Graph graph + Graph graph, + GraphStore graphStore ) { try (ProgressTimer ignored = ProgressTimer.start(timingsBuilder::withComputeMillis)) { - return computeWithMetric(label, algorithmComputation, graph); + return computeWithMetric(label, algorithmComputation, graph, graphStore); } } private RESULT_FROM_ALGORITHM computeWithMetric( LabelForProgressTracking label, AlgorithmComputation algorithmComputation, - Graph graph + Graph graph, + GraphStore graphStore ) { var executionMetric = algorithmMetricsService.create(label.value); try (executionMetric) { executionMetric.start(); - return algorithmComputation.compute(graph); + return algorithmComputation.compute(graph, graphStore); } catch (RuntimeException e) { log.warn("computation failed, halting metrics gathering", e); executionMetric.failed(e); diff --git a/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/metadata/Algorithm.java b/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/metadata/Algorithm.java index 80c147b206..e06c154df7 100644 --- a/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/metadata/Algorithm.java +++ b/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/metadata/Algorithm.java @@ -37,6 +37,7 @@ public enum Algorithm { BFS, CELF, ClosenessCentrality, + CollapsePath, Conductance, DegreeCentrality, DeltaStepping, diff --git a/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/metadata/LabelForProgressTracking.java b/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/metadata/LabelForProgressTracking.java index 0d4817c69d..49b5f0f031 100644 --- a/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/metadata/LabelForProgressTracking.java +++ b/applications/algorithms/machinery/src/main/java/org/neo4j/gds/applications/algorithms/metadata/LabelForProgressTracking.java @@ -30,6 +30,7 @@ public enum LabelForProgressTracking { BFS("BFS"), CELF("CELF"), ClosenessCentrality("Closeness Centrality"), + CollapsePath("CollapsePath"), Conductance("Conductance"), DegreeCentrality("DegreeCentrality"), DeltaStepping("Delta Stepping"), @@ -86,6 +87,7 @@ public static LabelForProgressTracking from(Algorithm algorithm) { case BFS -> BFS; case CELF -> CELF; case ClosenessCentrality -> ClosenessCentrality; + case CollapsePath -> CollapsePath; case Conductance -> Conductance; case DegreeCentrality -> DegreeCentrality; case DeltaStepping -> DeltaStepping; diff --git a/applications/algorithms/machinery/src/test/java/org/neo4j/gds/applications/algorithms/machinery/DefaultAlgorithmProcessingTemplateTest.java b/applications/algorithms/machinery/src/test/java/org/neo4j/gds/applications/algorithms/machinery/DefaultAlgorithmProcessingTemplateTest.java index b9cb9b65bb..9aae960c2a 100644 --- a/applications/algorithms/machinery/src/test/java/org/neo4j/gds/applications/algorithms/machinery/DefaultAlgorithmProcessingTemplateTest.java +++ b/applications/algorithms/machinery/src/test/java/org/neo4j/gds/applications/algorithms/machinery/DefaultAlgorithmProcessingTemplateTest.java @@ -85,7 +85,7 @@ void shouldProcessStreamAlgorithm() { //noinspection unchecked AlgorithmComputation computation = mock(AlgorithmComputation.class); var pathFindingResult = mock(ExampleResult.class); - when(computation.compute(graph)).thenReturn(pathFindingResult); + when(computation.compute(graph, graphStore)).thenReturn(pathFindingResult); var resultBuilder = new ResultBuilder, Void>() { @Override @@ -184,7 +184,7 @@ public String build( //noinspection unchecked AlgorithmComputation computation = mock(AlgorithmComputation.class); - when(computation.compute(graph)).thenReturn(pathFindingResult); + when(computation.compute(graph, graphStore)).thenReturn(pathFindingResult); var mutateOrWriteStep = new MutateOrWriteStep() { @Override @@ -240,7 +240,8 @@ RESULT_FROM_ALGORITHM computeWithTiming( AlgorithmProcessingTimingsBuilder timingsBuilder, LabelForProgressTracking label, AlgorithmComputation algorithmComputation, - Graph graph + Graph graph, + GraphStore graphStore ) { timingsBuilder.withComputeMillis(117); return null; diff --git a/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/CollapsePathMutateStep.java b/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/CollapsePathMutateStep.java new file mode 100644 index 0000000000..5bc1031387 --- /dev/null +++ b/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/CollapsePathMutateStep.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) "Neo4j" + * Neo4j Sweden AB [http://neo4j.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.neo4j.gds.applications.algorithms.miscellaneous; + +import org.neo4j.gds.api.Graph; +import org.neo4j.gds.api.GraphStore; +import org.neo4j.gds.api.ResultStore; +import org.neo4j.gds.applications.algorithms.machinery.MutateOrWriteStep; +import org.neo4j.gds.core.loading.SingleTypeRelationships; +import org.neo4j.gds.core.utils.progress.JobId; + +class CollapsePathMutateStep implements MutateOrWriteStep { + @Override + public Void execute( + Graph graph, + GraphStore graphStore, + ResultStore resultStore, + SingleTypeRelationships result, + JobId jobId + ) { + graphStore.addRelationshipType(result); + + return null; + } +} diff --git a/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousAlgorithms.java b/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousAlgorithms.java index e290d08145..ab00341e18 100644 --- a/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousAlgorithms.java +++ b/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousAlgorithms.java @@ -19,17 +19,29 @@ */ package org.neo4j.gds.applications.algorithms.miscellaneous; +import org.neo4j.gds.NodeLabel; +import org.neo4j.gds.RelationshipType; import org.neo4j.gds.api.Graph; +import org.neo4j.gds.api.GraphStore; import org.neo4j.gds.applications.algorithms.machinery.AlgorithmMachinery; import org.neo4j.gds.applications.algorithms.machinery.ProgressTrackerCreator; import org.neo4j.gds.applications.algorithms.metadata.LabelForProgressTracking; import org.neo4j.gds.core.concurrency.DefaultPool; +import org.neo4j.gds.core.loading.SingleTypeRelationships; import org.neo4j.gds.core.utils.progress.tasks.Tasks; import org.neo4j.gds.scaleproperties.ScaleProperties; import org.neo4j.gds.scaleproperties.ScalePropertiesBaseConfig; import org.neo4j.gds.scaleproperties.ScalePropertiesResult; +import org.neo4j.gds.walking.CollapsePath; +import org.neo4j.gds.walking.CollapsePathConfig; -public class MiscellaneousAlgorithms { +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +class MiscellaneousAlgorithms { private final AlgorithmMachinery algorithmMachinery = new AlgorithmMachinery(); private final ProgressTrackerCreator progressTrackerCreator; @@ -38,6 +50,39 @@ public class MiscellaneousAlgorithms { this.progressTrackerCreator = progressTrackerCreator; } + SingleTypeRelationships collapsePath(GraphStore graphStore, CollapsePathConfig configuration) { + Collection nodeLabels = configuration.nodeLabelIdentifiers(graphStore); + + /* + * here we build a graph-per-relationship type. you can think of them as layers. + * the algorithm will take a step in a layer, then a next step in another layer. + * that obviously stops of a node in a layer is not connected to anything. + */ + List pathTemplatesEncodedAsListsOfSingleRelationshipTypeGraphs = configuration.pathTemplates().stream() + .map( + path -> path.stream() + .map( + relationshipTypeAsString -> graphStore.getGraph( + nodeLabels, + Set.of(RelationshipType.of(relationshipTypeAsString)), + Optional.empty() + ) + ) + .toArray(Graph[]::new) + ) + .collect(Collectors.toList()); + + var algorithm = new CollapsePath( + pathTemplatesEncodedAsListsOfSingleRelationshipTypeGraphs, + configuration.allowSelfLoops(), + RelationshipType.of(configuration.mutateRelationshipType()), + configuration.concurrency(), + DefaultPool.INSTANCE + ); + + return algorithm.compute(); + } + ScalePropertiesResult scaleProperties(Graph graph, ScalePropertiesBaseConfig configuration) { int totalPropertyDimension = configuration .nodeProperties() diff --git a/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsEstimationModeBusinessFacade.java b/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsEstimationModeBusinessFacade.java index 337ca58e18..5a7c2f6c2e 100644 --- a/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsEstimationModeBusinessFacade.java +++ b/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsEstimationModeBusinessFacade.java @@ -21,6 +21,7 @@ import org.neo4j.gds.applications.algorithms.machinery.AlgorithmEstimationTemplate; import org.neo4j.gds.applications.algorithms.machinery.MemoryEstimateResult; +import org.neo4j.gds.exceptions.MemoryEstimationNotImplementedException; import org.neo4j.gds.mem.MemoryEstimation; import org.neo4j.gds.scaleproperties.ScalePropertiesBaseConfig; import org.neo4j.gds.scaleproperties.ScalePropertiesMemoryEstimateDefinition; @@ -36,6 +37,10 @@ public MemoryEstimation scaleProperties(ScalePropertiesBaseConfig configuration) return new ScalePropertiesMemoryEstimateDefinition(configuration.nodeProperties()).memoryEstimation(); } + public MemoryEstimation collapsePath() { + throw new MemoryEstimationNotImplementedException(); + } + public MemoryEstimateResult scaleProperties( ScalePropertiesBaseConfig configuration, Object graphNameOrConfiguration diff --git a/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsMutateModeBusinessFacade.java b/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsMutateModeBusinessFacade.java index 38ace1b081..dd05659e82 100644 --- a/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsMutateModeBusinessFacade.java +++ b/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsMutateModeBusinessFacade.java @@ -24,9 +24,12 @@ import org.neo4j.gds.applications.algorithms.machinery.MutateNodeProperty; import org.neo4j.gds.applications.algorithms.machinery.ResultBuilder; import org.neo4j.gds.applications.algorithms.metadata.NodePropertiesWritten; +import org.neo4j.gds.core.loading.SingleTypeRelationships; import org.neo4j.gds.scaleproperties.ScalePropertiesMutateConfig; import org.neo4j.gds.scaleproperties.ScalePropertiesResult; +import org.neo4j.gds.walking.CollapsePathConfig; +import static org.neo4j.gds.applications.algorithms.metadata.LabelForProgressTracking.CollapsePath; import static org.neo4j.gds.applications.algorithms.metadata.LabelForProgressTracking.ScaleProperties; public class MiscellaneousApplicationsMutateModeBusinessFacade { @@ -47,6 +50,24 @@ public class MiscellaneousApplicationsMutateModeBusinessFacade { this.mutateNodeProperty = mutateNodeProperty; } + public RESULT collapsePath( + GraphName graphName, + CollapsePathConfig configuration, + ResultBuilder resultBuilder + ) { + var mutateStep = new CollapsePathMutateStep(); + + return algorithmProcessingTemplateConvenience.processRegularAlgorithmInMutateOrWriteMode( + graphName, + configuration, + CollapsePath, + estimation::collapsePath, + (__, graphStore) -> algorithms.collapsePath(graphStore, configuration), + mutateStep, + resultBuilder + ); + } + public RESULT scaleProperties( GraphName graphName, ScalePropertiesMutateConfig configuration, @@ -59,7 +80,7 @@ public RESULT scaleProperties( configuration, ScaleProperties, () -> estimation.scaleProperties(configuration), - graph -> algorithms.scaleProperties(graph, configuration), + (graph, __) -> algorithms.scaleProperties(graph, configuration), mutateStep, resultBuilder ); diff --git a/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsStatsModeBusinessFacade.java b/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsStatsModeBusinessFacade.java index 3185be9032..15d64b41e1 100644 --- a/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsStatsModeBusinessFacade.java +++ b/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsStatsModeBusinessFacade.java @@ -52,7 +52,7 @@ public RESULT scaleProperties( configuration, ScaleProperties, () -> estimationFacade.scaleProperties(configuration), - graph -> miscellaneousAlgorithms.scaleProperties(graph, configuration), + (graph, __) -> miscellaneousAlgorithms.scaleProperties(graph, configuration), resultBuilder ); } diff --git a/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsStreamModeBusinessFacade.java b/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsStreamModeBusinessFacade.java index 1c3dec6ac4..0ae7ce27cf 100644 --- a/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsStreamModeBusinessFacade.java +++ b/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsStreamModeBusinessFacade.java @@ -52,7 +52,7 @@ public RESULT scaleProperties( configuration, ScaleProperties, () -> estimationFacade.scaleProperties(configuration), - graph -> miscellaneousAlgorithms.scaleProperties(graph, configuration), + (graph, __) -> miscellaneousAlgorithms.scaleProperties(graph, configuration), resultBuilder ); } diff --git a/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsWriteModeBusinessFacade.java b/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsWriteModeBusinessFacade.java index 17b731a65f..38ef45d6d4 100644 --- a/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsWriteModeBusinessFacade.java +++ b/applications/algorithms/miscellaneous-algorithms/src/main/java/org/neo4j/gds/applications/algorithms/miscellaneous/MiscellaneousApplicationsWriteModeBusinessFacade.java @@ -59,7 +59,7 @@ public RESULT scaleProperties( configuration, ScaleProperties, () -> estimationFacade.scaleProperties(configuration), - graph -> miscellaneousAlgorithms.scaleProperties(graph, configuration), + (graph, __) -> miscellaneousAlgorithms.scaleProperties(graph, configuration), writeStep, resultBuilder ); diff --git a/applications/algorithms/node-embeddings/build.gradle b/applications/algorithms/node-embeddings/build.gradle index a20f5a366e..e298bda89a 100644 --- a/applications/algorithms/node-embeddings/build.gradle +++ b/applications/algorithms/node-embeddings/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'java-library' -description = 'Neo4j Graph Data Science :: Node Embeddings' +description = 'Neo4j Graph Data Science :: Node Embedding Algorithms' group = 'org.neo4j.gds' diff --git a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/GraphSageAlgorithmProcessing.java b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/GraphSageAlgorithmProcessing.java index 137c3394d9..31dae3a871 100644 --- a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/GraphSageAlgorithmProcessing.java +++ b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/GraphSageAlgorithmProcessing.java @@ -68,7 +68,7 @@ RE Optional.of(List.of(validationHook)), GraphSage, () -> estimationFacade.graphSage(configuration, mutating), - graph -> algorithms.graphSage(graph, configuration), + (graph, __) -> algorithms.graphSage(graph, configuration), mutateOrWriteStep, resultBuilder ); diff --git a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/Node2VecAlgorithmProcessing.java b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/Node2VecAlgorithmProcessing.java index 9644ba5efa..b777282597 100644 --- a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/Node2VecAlgorithmProcessing.java +++ b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/Node2VecAlgorithmProcessing.java @@ -64,7 +64,7 @@ RES Optional.of(List.of(validationHook)), Node2Vec, () -> estimationFacade.node2Vec(configuration), - graph -> algorithms.node2Vec(graph, configuration), + (graph, __) -> algorithms.node2Vec(graph, configuration), mutateOrWriteStep, resultBuilder ); diff --git a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsMutateModeBusinessFacade.java b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsMutateModeBusinessFacade.java index 167764ff7a..0410bfc9b8 100644 --- a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsMutateModeBusinessFacade.java +++ b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsMutateModeBusinessFacade.java @@ -74,7 +74,7 @@ public RESULT fastRP( configuration, FastRP, () -> estimation.fastRP(configuration), - graph -> algorithms.fastRP(graph, configuration), + (graph, __) -> algorithms.fastRP(graph, configuration), mutateStep, resultBuilder ); @@ -108,7 +108,7 @@ public RESULT hashGnn( configuration, HashGNN, () -> estimation.hashGnn(configuration), - graph -> algorithms.hashGnn(graph, configuration), + (graph, __) -> algorithms.hashGnn(graph, configuration), mutateStep, resultBuilder ); diff --git a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsStatsModeBusinessFacade.java b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsStatsModeBusinessFacade.java index 301cb0f21d..43aed8e50d 100644 --- a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsStatsModeBusinessFacade.java +++ b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsStatsModeBusinessFacade.java @@ -32,7 +32,7 @@ public class NodeEmbeddingAlgorithmsStatsModeBusinessFacade { private final NodeEmbeddingAlgorithms algorithms; private final AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience; - public NodeEmbeddingAlgorithmsStatsModeBusinessFacade( + NodeEmbeddingAlgorithmsStatsModeBusinessFacade( NodeEmbeddingAlgorithmsEstimationModeBusinessFacade estimationFacade, NodeEmbeddingAlgorithms algorithms, AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience @@ -52,7 +52,7 @@ public RESULT fastRP( configuration, FastRP, () -> estimationFacade.fastRP(configuration), - graph -> algorithms.fastRP(graph, configuration), + (graph, __) -> algorithms.fastRP(graph, configuration), resultBuilder ); } diff --git a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsStreamModeBusinessFacade.java b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsStreamModeBusinessFacade.java index 04352d21fc..50f66f55a9 100644 --- a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsStreamModeBusinessFacade.java +++ b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsStreamModeBusinessFacade.java @@ -43,7 +43,7 @@ public class NodeEmbeddingAlgorithmsStreamModeBusinessFacade { private final GraphSageAlgorithmProcessing graphSageAlgorithmProcessing; private final Node2VecAlgorithmProcessing node2VecAlgorithmProcessing; - public NodeEmbeddingAlgorithmsStreamModeBusinessFacade( + NodeEmbeddingAlgorithmsStreamModeBusinessFacade( NodeEmbeddingAlgorithmsEstimationModeBusinessFacade estimationFacade, NodeEmbeddingAlgorithms algorithms, AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience, @@ -67,7 +67,7 @@ public RESULT fastRP( configuration, FastRP, () -> estimationFacade.fastRP(configuration), - graph -> algorithms.fastRP(graph, configuration), + (graph, __) -> algorithms.fastRP(graph, configuration), resultBuilder ); } @@ -90,7 +90,7 @@ public RESULT hashGnn( configuration, HashGNN, () -> estimationFacade.hashGnn(configuration), - graph -> algorithms.hashGnn(graph, configuration), + (graph, __) -> algorithms.hashGnn(graph, configuration), resultBuilder ); } diff --git a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsTrainModeBusinessFacade.java b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsTrainModeBusinessFacade.java index 74e9ca74c1..91f3e53009 100644 --- a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsTrainModeBusinessFacade.java +++ b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsTrainModeBusinessFacade.java @@ -39,7 +39,7 @@ public class NodeEmbeddingAlgorithmsTrainModeBusinessFacade { private final NodeEmbeddingAlgorithms algorithms; private final AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience; - public NodeEmbeddingAlgorithmsTrainModeBusinessFacade( + NodeEmbeddingAlgorithmsTrainModeBusinessFacade( GraphSageModelCatalog graphSageModelCatalog, GraphSageModelRepository graphSageModelRepository, NodeEmbeddingAlgorithmsEstimationModeBusinessFacade estimation, @@ -73,7 +73,7 @@ public RESULT graphSage( Optional.of(List.of(validationHook)), GraphSageTrain, () -> estimation.graphSageTrain(configuration), - graph -> algorithms.graphSageTrain(graph, configuration), + (graph, __) -> algorithms.graphSageTrain(graph, configuration), Optional.of(writeToDiskStep), resultBuilder ); diff --git a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsWriteModeBusinessFacade.java b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsWriteModeBusinessFacade.java index 4403f03704..14497f71a9 100644 --- a/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsWriteModeBusinessFacade.java +++ b/applications/algorithms/node-embeddings/src/main/java/org/neo4j/gds/applications/algorithms/embeddings/NodeEmbeddingAlgorithmsWriteModeBusinessFacade.java @@ -95,7 +95,7 @@ public RESULT fastRP( configuration, FastRP, () -> estimationFacade.fastRP(configuration), - graph -> algorithms.fastRP(graph, configuration), + (graph, __) -> algorithms.fastRP(graph, configuration), writeStep, resultBuilder ); diff --git a/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsMutateModeBusinessFacade.java b/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsMutateModeBusinessFacade.java index 5713b9841f..cff4dd4089 100644 --- a/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsMutateModeBusinessFacade.java +++ b/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsMutateModeBusinessFacade.java @@ -82,7 +82,7 @@ public RESULT bellmanFord( configuration, BellmanFord, () -> estimationFacade.bellmanFord(configuration), - graph -> pathFindingAlgorithms.bellmanFord(graph, configuration), + (graph, __) -> pathFindingAlgorithms.bellmanFord(graph, configuration), mutateStep, resultBuilder ); @@ -101,7 +101,7 @@ public RESULT breadthFirstSearch( configuration, BFS, estimationFacade::breadthFirstSearch, - graph -> pathFindingAlgorithms.breadthFirstSearch(graph, configuration), + (graph, __) -> pathFindingAlgorithms.breadthFirstSearch(graph, configuration), mutateStep, resultBuilder ); @@ -119,7 +119,7 @@ public RESULT deltaStepping( configuration, DeltaStepping, estimationFacade::deltaStepping, - graph -> pathFindingAlgorithms.deltaStepping(graph, configuration), + (graph, __) -> pathFindingAlgorithms.deltaStepping(graph, configuration), mutateStep, resultBuilder ); @@ -138,7 +138,7 @@ public RESULT depthFirstSearch( configuration, DFS, estimationFacade::depthFirstSearch, - graph -> pathFindingAlgorithms.depthFirstSearch(graph, configuration), + (graph, __) -> pathFindingAlgorithms.depthFirstSearch(graph, configuration), mutateStep, resultBuilder ); @@ -156,7 +156,7 @@ public RESULT singlePairShortestPathAStar( configuration, AStar, estimationFacade::singlePairShortestPathAStar, - graph -> pathFindingAlgorithms.singlePairShortestPathAStar(graph, configuration), + (graph, __) -> pathFindingAlgorithms.singlePairShortestPathAStar(graph, configuration), mutateStep, resultBuilder ); @@ -174,7 +174,7 @@ public RESULT singlePairShortestPathDijkstra( configuration, Dijkstra, () -> estimationFacade.singlePairShortestPathDijkstra(configuration), - graph -> pathFindingAlgorithms.singlePairShortestPathDijkstra(graph, configuration), + (graph, __) -> pathFindingAlgorithms.singlePairShortestPathDijkstra(graph, configuration), mutateStep, resultBuilder ); @@ -192,7 +192,7 @@ public RESULT singlePairShortestPathYens( configuration, Yens, () -> estimationFacade.singlePairShortestPathYens(configuration), - graph -> pathFindingAlgorithms.singlePairShortestPathYens(graph, configuration), + (graph, __) -> pathFindingAlgorithms.singlePairShortestPathYens(graph, configuration), mutateStep, resultBuilder ); @@ -210,7 +210,7 @@ public RESULT singleSourceShortestPathDijkstra( configuration, SingleSourceDijkstra, () -> estimationFacade.singleSourceShortestPathDijkstra(configuration), - graph -> pathFindingAlgorithms.singleSourceShortestPathDijkstra(graph, configuration), + (graph, __) -> pathFindingAlgorithms.singleSourceShortestPathDijkstra(graph, configuration), mutateStep, resultBuilder ); @@ -228,7 +228,7 @@ public RESULT spanningTree( configuration, LabelForProgressTracking.SpanningTree, estimationFacade::spanningTree, - graph -> pathFindingAlgorithms.spanningTree(graph, configuration), + (graph, __) -> pathFindingAlgorithms.spanningTree(graph, configuration), mutateStep, resultBuilder ); @@ -246,7 +246,7 @@ public RESULT steinerTree( configuration, SteinerTree, () -> estimationFacade.steinerTree(configuration), - graph -> pathFindingAlgorithms.steinerTree(graph, configuration), + (graph, __) -> pathFindingAlgorithms.steinerTree(graph, configuration), mutateStep, resultBuilder ); diff --git a/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsStatsModeBusinessFacade.java b/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsStatsModeBusinessFacade.java index e9adc0ea78..80ffb33c0a 100644 --- a/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsStatsModeBusinessFacade.java +++ b/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsStatsModeBusinessFacade.java @@ -49,7 +49,7 @@ public class PathFindingAlgorithmsStatsModeBusinessFacade { private final PathFindingAlgorithmsEstimationModeBusinessFacade estimationFacade; private final PathFindingAlgorithms pathFindingAlgorithms; - public PathFindingAlgorithmsStatsModeBusinessFacade( + PathFindingAlgorithmsStatsModeBusinessFacade( AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience, PathFindingAlgorithmsEstimationModeBusinessFacade estimationFacade, PathFindingAlgorithms pathFindingAlgorithms @@ -69,7 +69,7 @@ public RESULT bellmanFord( configuration, BellmanFord, () -> estimationFacade.bellmanFord(configuration), - graph -> pathFindingAlgorithms.bellmanFord(graph, configuration), + (graph, __) -> pathFindingAlgorithms.bellmanFord(graph, configuration), resultBuilder ); } @@ -84,7 +84,7 @@ public RESULT breadthFirstSearch( configuration, BFS, estimationFacade::breadthFirstSearch, - graph -> pathFindingAlgorithms.breadthFirstSearch(graph, configuration), + (graph, __) -> pathFindingAlgorithms.breadthFirstSearch(graph, configuration), resultBuilder ); } @@ -99,7 +99,7 @@ public RESULT deltaStepping( configuration, DeltaStepping, estimationFacade::deltaStepping, - graph -> pathFindingAlgorithms.deltaStepping(graph, configuration), + (graph, __) -> pathFindingAlgorithms.deltaStepping(graph, configuration), resultBuilder ); } @@ -114,7 +114,7 @@ public RESULT randomWalk( configuration, RandomWalk, () -> estimationFacade.randomWalk(configuration), - graph -> pathFindingAlgorithms.randomWalk(graph, configuration), + (graph, __) -> pathFindingAlgorithms.randomWalk(graph, configuration), resultBuilder ); } @@ -129,7 +129,7 @@ public RESULT spanningTree( configuration, LabelForProgressTracking.SpanningTree, estimationFacade::spanningTree, - graph -> pathFindingAlgorithms.spanningTree(graph, configuration), + (graph, __) -> pathFindingAlgorithms.spanningTree(graph, configuration), resultBuilder ); } @@ -144,7 +144,7 @@ public RESULT steinerTree( configuration, SteinerTree, () -> estimationFacade.steinerTree(configuration), - graph -> pathFindingAlgorithms.steinerTree(graph, configuration), + (graph, __) -> pathFindingAlgorithms.steinerTree(graph, configuration), resultBuilder ); } diff --git a/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsStreamModeBusinessFacade.java b/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsStreamModeBusinessFacade.java index b78f145da4..663c8e7f0a 100644 --- a/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsStreamModeBusinessFacade.java +++ b/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsStreamModeBusinessFacade.java @@ -71,7 +71,7 @@ public class PathFindingAlgorithmsStreamModeBusinessFacade { private final PathFindingAlgorithmsEstimationModeBusinessFacade estimationFacade; private final PathFindingAlgorithms pathFindingAlgorithms; - public PathFindingAlgorithmsStreamModeBusinessFacade( + PathFindingAlgorithmsStreamModeBusinessFacade( AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience, PathFindingAlgorithmsEstimationModeBusinessFacade estimationFacade, PathFindingAlgorithms pathFindingAlgorithms @@ -91,7 +91,7 @@ public RESULT allShortestPaths( configuration, AllShortestPaths, estimationFacade::allShortestPaths, - graph -> pathFindingAlgorithms.allShortestPaths(graph, configuration), + (graph, __) -> pathFindingAlgorithms.allShortestPaths(graph, configuration), resultBuilder ); } @@ -106,7 +106,7 @@ public RESULT bellmanFord( configuration, BellmanFord, () -> estimationFacade.bellmanFord(configuration), - graph -> pathFindingAlgorithms.bellmanFord(graph, configuration), + (graph, __) -> pathFindingAlgorithms.bellmanFord(graph, configuration), resultBuilder ); } @@ -121,7 +121,7 @@ public RESULT breadthFirstSearch( configuration, BFS, estimationFacade::breadthFirstSearch, - graph -> pathFindingAlgorithms.breadthFirstSearch(graph, configuration), + (graph, __) -> pathFindingAlgorithms.breadthFirstSearch(graph, configuration), resultBuilder ); } @@ -136,7 +136,7 @@ public RESULT deltaStepping( configuration, DeltaStepping, estimationFacade::deltaStepping, - graph -> pathFindingAlgorithms.deltaStepping(graph, configuration), + (graph, __) -> pathFindingAlgorithms.deltaStepping(graph, configuration), resultBuilder ); } @@ -151,7 +151,7 @@ public RESULT depthFirstSearch( configuration, DFS, estimationFacade::depthFirstSearch, - graph -> pathFindingAlgorithms.depthFirstSearch(graph, configuration), + (graph, __) -> pathFindingAlgorithms.depthFirstSearch(graph, configuration), resultBuilder ); } @@ -166,7 +166,7 @@ public RESULT longestPath( configuration, LongestPath, estimationFacade::longestPath, - graph -> pathFindingAlgorithms.longestPath(graph, configuration), + (graph, __) -> pathFindingAlgorithms.longestPath(graph, configuration), resultBuilder ); } @@ -181,7 +181,7 @@ public RESULT randomWalk( configuration, RandomWalk, () -> estimationFacade.randomWalk(configuration), - graph -> pathFindingAlgorithms.randomWalk(graph, configuration), + (graph, __) -> pathFindingAlgorithms.randomWalk(graph, configuration), resultBuilder ); } @@ -196,7 +196,7 @@ public RESULT singlePairShortestPathAStar( configuration, AStar, estimationFacade::singlePairShortestPathAStar, - graph -> pathFindingAlgorithms.singlePairShortestPathAStar(graph, configuration), + (graph, __) -> pathFindingAlgorithms.singlePairShortestPathAStar(graph, configuration), resultBuilder ); } @@ -211,7 +211,7 @@ public RESULT singlePairShortestPathDijkstra( configuration, Dijkstra, () -> estimationFacade.singlePairShortestPathDijkstra(configuration), - graph -> pathFindingAlgorithms.singlePairShortestPathDijkstra(graph, configuration), + (graph, __) -> pathFindingAlgorithms.singlePairShortestPathDijkstra(graph, configuration), resultBuilder ); } @@ -226,7 +226,7 @@ public RESULT singlePairShortestPathYens( configuration, Yens, () -> estimationFacade.singlePairShortestPathYens(configuration), - graph -> pathFindingAlgorithms.singlePairShortestPathYens(graph, configuration), + (graph, __) -> pathFindingAlgorithms.singlePairShortestPathYens(graph, configuration), resultBuilder ); } @@ -241,7 +241,7 @@ public RESULT singleSourceShortestPathDijkstra( configuration, SingleSourceDijkstra, () -> estimationFacade.singleSourceShortestPathDijkstra(configuration), - graph -> pathFindingAlgorithms.singleSourceShortestPathDijkstra(graph, configuration), + (graph, __) -> pathFindingAlgorithms.singleSourceShortestPathDijkstra(graph, configuration), resultBuilder ); } @@ -256,7 +256,7 @@ public RESULT spanningTree( configuration, LabelForProgressTracking.SpanningTree, estimationFacade::spanningTree, - graph -> pathFindingAlgorithms.spanningTree(graph, configuration), + (graph, __) -> pathFindingAlgorithms.spanningTree(graph, configuration), resultBuilder ); } @@ -271,7 +271,7 @@ public RESULT steinerTree( configuration, SteinerTree, () -> estimationFacade.steinerTree(configuration), - graph -> pathFindingAlgorithms.steinerTree(graph, configuration), + (graph, __) -> pathFindingAlgorithms.steinerTree(graph, configuration), resultBuilder ); } @@ -286,7 +286,7 @@ public RESULT topologicalSort( configuration, TopologicalSort, estimationFacade::topologicalSort, - graph -> pathFindingAlgorithms.topologicalSort(graph, configuration), + (graph, __) -> pathFindingAlgorithms.topologicalSort(graph, configuration), resultBuilder ); } diff --git a/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsWriteModeBusinessFacade.java b/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsWriteModeBusinessFacade.java index 32a19e3165..c50cbdd472 100644 --- a/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsWriteModeBusinessFacade.java +++ b/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsWriteModeBusinessFacade.java @@ -72,7 +72,7 @@ public class PathFindingAlgorithmsWriteModeBusinessFacade { private final PathFindingAlgorithmsEstimationModeBusinessFacade estimationFacade; private final PathFindingAlgorithms pathFindingAlgorithms; - public PathFindingAlgorithmsWriteModeBusinessFacade( + PathFindingAlgorithmsWriteModeBusinessFacade( Log log, AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience, RequestScopedDependencies requestScopedDependencies, @@ -105,7 +105,7 @@ public RESULT bellmanFord( configuration, BellmanFord, () -> estimationFacade.bellmanFord(configuration), - graph -> pathFindingAlgorithms.bellmanFord(graph, configuration), + (graph, __) -> pathFindingAlgorithms.bellmanFord(graph, configuration), writeStep, resultBuilder ); @@ -121,7 +121,7 @@ public RESULT deltaStepping( configuration, DeltaStepping, estimationFacade::deltaStepping, - graph -> pathFindingAlgorithms.deltaStepping(graph, configuration), + (graph, __) -> pathFindingAlgorithms.deltaStepping(graph, configuration), resultBuilder ); } @@ -143,7 +143,7 @@ public RESULT kSpanningTree( configuration, KSpanningTree, estimationFacade::kSpanningTree, - graph -> pathFindingAlgorithms.kSpanningTree(graph, configuration), + (graph, __) -> pathFindingAlgorithms.kSpanningTree(graph, configuration), writeStep, resultBuilder ); @@ -159,7 +159,7 @@ public RESULT singlePairShortestPathAStar( configuration, AStar, estimationFacade::singlePairShortestPathAStar, - graph -> pathFindingAlgorithms.singlePairShortestPathAStar(graph, configuration), + (graph, __) -> pathFindingAlgorithms.singlePairShortestPathAStar(graph, configuration), resultBuilder ); } @@ -174,7 +174,7 @@ public RESULT singlePairShortestPathDijkstra( configuration, Dijkstra, () -> estimationFacade.singlePairShortestPathDijkstra(configuration), - graph -> pathFindingAlgorithms.singlePairShortestPathDijkstra(graph, configuration), + (graph, __) -> pathFindingAlgorithms.singlePairShortestPathDijkstra(graph, configuration), resultBuilder ); } @@ -189,7 +189,7 @@ public RESULT singlePairShortestPathYens( configuration, Yens, () -> estimationFacade.singlePairShortestPathYens(configuration), - graph -> pathFindingAlgorithms.singlePairShortestPathYens(graph, configuration), + (graph, __) -> pathFindingAlgorithms.singlePairShortestPathYens(graph, configuration), resultBuilder ); } @@ -204,7 +204,7 @@ public RESULT singleSourceShortestPathDijkstra( configuration, SingleSourceDijkstra, () -> estimationFacade.singleSourceShortestPathDijkstra(configuration), - graph -> pathFindingAlgorithms.singleSourceShortestPathDijkstra(graph, configuration), + (graph, __) -> pathFindingAlgorithms.singleSourceShortestPathDijkstra(graph, configuration), resultBuilder ); } @@ -226,7 +226,7 @@ public RESULT spanningTree( configuration, LabelForProgressTracking.SpanningTree, estimationFacade::spanningTree, - graph -> pathFindingAlgorithms.spanningTree(graph, configuration), + (graph, __) -> pathFindingAlgorithms.spanningTree(graph, configuration), writeStep, resultBuilder ); @@ -244,7 +244,7 @@ public RESULT steinerTree( configuration, SteinerTree, () -> estimationFacade.steinerTree(configuration), - graph -> pathFindingAlgorithms.steinerTree(graph, configuration), + (graph, __) -> pathFindingAlgorithms.steinerTree(graph, configuration), writeStep, resultBuilder ); diff --git a/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsMutateModeBusinessFacade.java b/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsMutateModeBusinessFacade.java index 5572a05b38..78e628215c 100644 --- a/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsMutateModeBusinessFacade.java +++ b/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsMutateModeBusinessFacade.java @@ -70,7 +70,7 @@ public RESULT filteredKnn( configuration, FilteredKNN, () -> estimationFacade.filteredKnn(configuration), - graph -> similarityAlgorithms.filteredKnn(graph, configuration), + (graph, __) -> similarityAlgorithms.filteredKnn(graph, configuration), mutateStep, resultBuilder ); @@ -93,7 +93,7 @@ public RESULT filteredNodeSimilarity( configuration, FilteredNodeSimilarity, () -> estimationFacade.filteredNodeSimilarity(configuration), - graph -> similarityAlgorithms.filteredNodeSimilarity(graph, configuration), + (graph, __) -> similarityAlgorithms.filteredNodeSimilarity(graph, configuration), mutateStep, resultBuilder ); @@ -112,7 +112,7 @@ public RESULT knn( configuration, KNN, () -> estimationFacade.knn(configuration), - graph -> similarityAlgorithms.knn(graph, configuration), + (graph, __) -> similarityAlgorithms.knn(graph, configuration), mutateStep, resultBuilder ); @@ -131,7 +131,7 @@ public RESULT nodeSimilarity( configuration, NodeSimilarity, () -> estimationFacade.nodeSimilarity(configuration), - graph -> similarityAlgorithms.nodeSimilarity(graph, configuration), + (graph, __) -> similarityAlgorithms.nodeSimilarity(graph, configuration), mutateStep, resultBuilder ); diff --git a/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsStatsModeBusinessFacade.java b/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsStatsModeBusinessFacade.java index e53f4b4a1f..ed7e4438b2 100644 --- a/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsStatsModeBusinessFacade.java +++ b/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsStatsModeBusinessFacade.java @@ -40,7 +40,7 @@ public class SimilarityAlgorithmsStatsModeBusinessFacade { private final SimilarityAlgorithms similarityAlgorithms; private final AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience; - public SimilarityAlgorithmsStatsModeBusinessFacade( + SimilarityAlgorithmsStatsModeBusinessFacade( SimilarityAlgorithmsEstimationModeBusinessFacade estimationFacade, SimilarityAlgorithms similarityAlgorithms, AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience @@ -60,7 +60,7 @@ public RESULT filteredKnn( configuration, FilteredKNN, () -> estimationFacade.filteredKnn(configuration), - graph -> similarityAlgorithms.filteredKnn(graph, configuration), + (graph, __) -> similarityAlgorithms.filteredKnn(graph, configuration), resultBuilder ); } @@ -75,7 +75,7 @@ public RESULT filteredNodeSimilarity( configuration, FilteredNodeSimilarity, () -> estimationFacade.filteredNodeSimilarity(configuration), - graph -> similarityAlgorithms.filteredNodeSimilarity(graph, configuration), + (graph, __) -> similarityAlgorithms.filteredNodeSimilarity(graph, configuration), resultBuilder ); } @@ -90,7 +90,7 @@ public RESULT knn( configuration, KNN, () -> estimationFacade.knn(configuration), - graph -> similarityAlgorithms.knn(graph, configuration), + (graph, __) -> similarityAlgorithms.knn(graph, configuration), resultBuilder ); } @@ -105,7 +105,7 @@ public RESULT nodeSimilarity( configuration, NodeSimilarity, () -> estimationFacade.nodeSimilarity(configuration), - graph -> similarityAlgorithms.nodeSimilarity(graph, configuration), + (graph, __) -> similarityAlgorithms.nodeSimilarity(graph, configuration), resultBuilder ); } diff --git a/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsStreamModeBusinessFacade.java b/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsStreamModeBusinessFacade.java index e7442041ab..dcd1d2e8ee 100644 --- a/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsStreamModeBusinessFacade.java +++ b/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsStreamModeBusinessFacade.java @@ -40,7 +40,7 @@ public class SimilarityAlgorithmsStreamModeBusinessFacade { private final SimilarityAlgorithms similarityAlgorithms; private final AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience; - public SimilarityAlgorithmsStreamModeBusinessFacade( + SimilarityAlgorithmsStreamModeBusinessFacade( SimilarityAlgorithmsEstimationModeBusinessFacade estimationFacade, SimilarityAlgorithms similarityAlgorithms, AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience @@ -60,7 +60,7 @@ public RESULT filteredKnn( configuration, FilteredKNN, () -> estimationFacade.filteredKnn(configuration), - graph -> similarityAlgorithms.filteredKnn(graph, configuration), + (graph, __) -> similarityAlgorithms.filteredKnn(graph, configuration), resultBuilder ); } @@ -75,7 +75,7 @@ public RESULT filteredNodeSimilarity( configuration, FilteredNodeSimilarity, () -> estimationFacade.filteredNodeSimilarity(configuration), - graph -> similarityAlgorithms.filteredNodeSimilarity(graph, configuration), + (graph, __) -> similarityAlgorithms.filteredNodeSimilarity(graph, configuration), resultBuilder ); } @@ -90,7 +90,7 @@ public RESULT knn( configuration, KNN, () -> estimationFacade.knn(configuration), - graph -> similarityAlgorithms.knn(graph, configuration), + (graph, __) -> similarityAlgorithms.knn(graph, configuration), resultBuilder ); } @@ -105,7 +105,7 @@ public RESULT nodeSimilarity( configuration, NodeSimilarity, () -> estimationFacade.nodeSimilarity(configuration), - graph -> similarityAlgorithms.nodeSimilarity(graph, configuration), + (graph, __) -> similarityAlgorithms.nodeSimilarity(graph, configuration), resultBuilder ); } diff --git a/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsWriteModeBusinessFacade.java b/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsWriteModeBusinessFacade.java index 4b77ea644d..b0251795b0 100644 --- a/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsWriteModeBusinessFacade.java +++ b/applications/algorithms/similarity/src/main/java/org/neo4j/gds/applications/algorithms/similarity/SimilarityAlgorithmsWriteModeBusinessFacade.java @@ -46,7 +46,7 @@ public class SimilarityAlgorithmsWriteModeBusinessFacade { private final AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience; private final WriteRelationshipService writeRelationshipService; - public SimilarityAlgorithmsWriteModeBusinessFacade( + SimilarityAlgorithmsWriteModeBusinessFacade( SimilarityAlgorithmsEstimationModeBusinessFacade estimationFacade, SimilarityAlgorithms similarityAlgorithms, AlgorithmProcessingTemplateConvenience algorithmProcessingTemplateConvenience, @@ -75,7 +75,7 @@ public RESULT filteredKnn( configuration, FilteredKNN, () -> estimationFacade.filteredKnn(configuration), - graph -> similarityAlgorithms.filteredKnn(graph, configuration), + (graph, __) -> similarityAlgorithms.filteredKnn(graph, configuration), writeStep, resultBuilder ); @@ -98,7 +98,7 @@ public RESULT filteredNodeSimilarity( configuration, FilteredNodeSimilarity, () -> estimationFacade.filteredNodeSimilarity(configuration), - graph -> similarityAlgorithms.filteredNodeSimilarity(graph, configuration), + (graph, __) -> similarityAlgorithms.filteredNodeSimilarity(graph, configuration), writeStep, resultBuilder ); @@ -121,7 +121,7 @@ public RESULT knn( configuration, KNN, () -> estimationFacade.knn(configuration), - graph -> similarityAlgorithms.knn(graph, configuration), + (graph, __) -> similarityAlgorithms.knn(graph, configuration), writeStep, resultBuilder ); @@ -144,7 +144,7 @@ public RESULT nodeSimilarity( configuration, NodeSimilarity, () -> estimationFacade.nodeSimilarity(configuration), - graph -> similarityAlgorithms.nodeSimilarity(graph, configuration), + (graph, __) -> similarityAlgorithms.nodeSimilarity(graph, configuration), writeStep, resultBuilder ); diff --git a/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/ConfigurationParsersForMutateMode.java b/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/ConfigurationParsersForMutateMode.java index e5915f8414..981d2b3c56 100644 --- a/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/ConfigurationParsersForMutateMode.java +++ b/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/ConfigurationParsersForMutateMode.java @@ -59,6 +59,7 @@ import org.neo4j.gds.steiner.SteinerTreeMutateConfig; import org.neo4j.gds.triangle.LocalClusteringCoefficientMutateConfig; import org.neo4j.gds.triangle.TriangleCountMutateConfig; +import org.neo4j.gds.walking.CollapsePathConfig; import org.neo4j.gds.wcc.WccMutateConfig; import java.util.function.Function; @@ -82,6 +83,7 @@ public Function lookup(Algorithm algorithm) { case BFS -> BfsMutateConfig::of; case CELF -> InfluenceMaximizationMutateConfig::of; case ClosenessCentrality -> ClosenessCentralityMutateConfig::of; + case CollapsePath -> CollapsePathConfig::of; case Conductance -> null; case DegreeCentrality -> DegreeCentralityMutateConfig::of; case DeltaStepping -> AllShortestPathsDeltaMutateConfig::of; diff --git a/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/MutateModeAlgorithmLibrary.java b/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/MutateModeAlgorithmLibrary.java index 7b272a8f81..db9cec2f7f 100644 --- a/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/MutateModeAlgorithmLibrary.java +++ b/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/MutateModeAlgorithmLibrary.java @@ -68,6 +68,7 @@ static CanonicalProcedureName algorithmToName(Algorithm algorithm) { case BFS -> CanonicalProcedureName.parse("gds.bfs"); case CELF -> CanonicalProcedureName.parse("gds.influenceMaximization.celf"); case ClosenessCentrality -> CanonicalProcedureName.parse("gds.closeness"); + case CollapsePath -> CanonicalProcedureName.parse("gds.collapsePath"); case Conductance -> null; case DegreeCentrality -> CanonicalProcedureName.parse("gds.degree"); case DeltaStepping -> CanonicalProcedureName.parse("gds.allShortestPaths.delta"); diff --git a/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/StubbyHolder.java b/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/StubbyHolder.java index a7fb7b6d0a..6c37d8e3bd 100644 --- a/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/StubbyHolder.java +++ b/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/StubbyHolder.java @@ -28,6 +28,7 @@ import org.neo4j.gds.ml.pipeline.stubs.BreadthFirstSearchStub; import org.neo4j.gds.ml.pipeline.stubs.CelfStub; import org.neo4j.gds.ml.pipeline.stubs.ClosenessCentralityStub; +import org.neo4j.gds.ml.pipeline.stubs.CollapsePathStub; import org.neo4j.gds.ml.pipeline.stubs.DegreeCentralityStub; import org.neo4j.gds.ml.pipeline.stubs.DepthFirstSearchStub; import org.neo4j.gds.ml.pipeline.stubs.EigenVectorStub; @@ -82,6 +83,7 @@ Stub get(Algorithm algorithm) { case BFS -> new BreadthFirstSearchStub(); case CELF -> new CelfStub(); case ClosenessCentrality -> new ClosenessCentralityStub(); + case CollapsePath -> new CollapsePathStub(); case Conductance -> null; case DegreeCentrality -> new DegreeCentralityStub(); case DeltaStepping -> new SingleSourceShortestPathDeltaStub(); diff --git a/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/stubs/CollapsePathStub.java b/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/stubs/CollapsePathStub.java new file mode 100644 index 0000000000..1169f22766 --- /dev/null +++ b/pipeline/src/main/java/org/neo4j/gds/ml/pipeline/stubs/CollapsePathStub.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) "Neo4j" + * Neo4j Sweden AB [http://neo4j.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.neo4j.gds.ml.pipeline.stubs; + +import org.neo4j.gds.procedures.algorithms.AlgorithmsProcedureFacade; +import org.neo4j.gds.procedures.algorithms.miscellaneous.CollapsePathMutateResult; +import org.neo4j.gds.procedures.algorithms.stubs.MutateStub; +import org.neo4j.gds.walking.CollapsePathConfig; + +public class CollapsePathStub extends AbstractStub { + protected MutateStub stub(AlgorithmsProcedureFacade facade) { + return facade.miscellaneous().collapsePathMutateStub(); + } +} diff --git a/proc/misc/src/main/java/org/neo4j/gds/walking/CollapsePathMutateProc.java b/proc/misc/src/main/java/org/neo4j/gds/walking/CollapsePathMutateProc.java index b0577cf581..0b63a65810 100644 --- a/proc/misc/src/main/java/org/neo4j/gds/walking/CollapsePathMutateProc.java +++ b/proc/misc/src/main/java/org/neo4j/gds/walking/CollapsePathMutateProc.java @@ -19,8 +19,9 @@ */ package org.neo4j.gds.walking; -import org.neo4j.gds.BaseProc; -import org.neo4j.gds.executor.ProcedureExecutor; +import org.neo4j.gds.procedures.GraphDataScienceProcedures; +import org.neo4j.gds.procedures.algorithms.miscellaneous.CollapsePathMutateResult; +import org.neo4j.procedure.Context; import org.neo4j.procedure.Description; import org.neo4j.procedure.Internal; import org.neo4j.procedure.Name; @@ -31,40 +32,35 @@ import static org.neo4j.procedure.Mode.READ; -public class CollapsePathMutateProc extends BaseProc { +public class CollapsePathMutateProc { static final String DESCRIPTION = "Collapse Path algorithm is a traversal algorithm capable of creating relationships between the start and end nodes of a traversal"; + @Context + public GraphDataScienceProcedures facade; + @Procedure(name = "gds.collapsePath.mutate", mode = READ) @Description(DESCRIPTION) - public Stream mutate( + public Stream mutate( @Name(value = "graphName") String graphName, @Name(value = "configuration", defaultValue = "{}") Map configuration ) { - return new ProcedureExecutor<>( - new CollapsePathMutateSpec(), - executionContext() - ).compute(graphName, configuration); + return facade.algorithms().miscellaneous().collapsePathMutateStub().execute(graphName, configuration); } @Procedure(name = "gds.beta.collapsePath.mutate", mode = READ, deprecatedBy = "gds.collapsePath.mutate") @Description(DESCRIPTION) @Deprecated(forRemoval = true) @Internal - public Stream betaMutate( + public Stream betaMutate( @Name(value = "graphName") String graphName, @Name(value = "configuration", defaultValue = "{}") Map configuration ) { - executionContext() - .metricsFacade() - .deprecatedProcedures().called("gds.beta.collapsePath.mutate"); - - executionContext() + facade.deprecatedProcedures().called("gds.beta.collapsePath.mutate"); + facade .log() .warn("Procedure `gds.beta.collapsePath.mutate` has been deprecated, please use `gds.collapsePath.mutate`."); return mutate(graphName, configuration); } - - } diff --git a/proc/misc/src/main/java/org/neo4j/gds/walking/CollapsePathMutateSpec.java b/proc/misc/src/main/java/org/neo4j/gds/walking/CollapsePathMutateSpec.java index a8b036cb44..43975fe613 100644 --- a/proc/misc/src/main/java/org/neo4j/gds/walking/CollapsePathMutateSpec.java +++ b/proc/misc/src/main/java/org/neo4j/gds/walking/CollapsePathMutateSpec.java @@ -27,6 +27,7 @@ import org.neo4j.gds.executor.ExecutionContext; import org.neo4j.gds.executor.GdsCallable; import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; +import org.neo4j.gds.procedures.algorithms.miscellaneous.CollapsePathMutateResult; import org.neo4j.gds.result.AbstractResultBuilder; import java.util.stream.Stream; @@ -40,7 +41,7 @@ description = DESCRIPTION, executionMode = MUTATE_RELATIONSHIP ) -public class CollapsePathMutateSpec implements AlgorithmSpec, CollapsePathAlgorithmFactory> { +public class CollapsePathMutateSpec implements AlgorithmSpec, CollapsePathAlgorithmFactory> { @Override public String name() { @@ -58,7 +59,7 @@ public NewConfigFunction newConfigFunction() { } @Override - public ComputationResultConsumer> computationResultConsumer() { + public ComputationResultConsumer> computationResultConsumer() { return new MutateComputationResultConsumer<>(this::resultBuilder) { @Override protected void updateGraphStore( @@ -75,11 +76,11 @@ protected void updateGraphStore( } - private AbstractResultBuilder resultBuilder( + private AbstractResultBuilder resultBuilder( ComputationResult computeResult, ExecutionContext executionContext ) { - return new MutateResult.Builder(); + return new CollapsePathMutateResult.Builder(); } } diff --git a/proc/misc/src/main/java/org/neo4j/gds/walking/MutateResult.java b/procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/CollapsePathMutateResult.java similarity index 68% rename from proc/misc/src/main/java/org/neo4j/gds/walking/MutateResult.java rename to procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/CollapsePathMutateResult.java index ffeb1c503e..610a6197c9 100644 --- a/proc/misc/src/main/java/org/neo4j/gds/walking/MutateResult.java +++ b/procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/CollapsePathMutateResult.java @@ -17,14 +17,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package org.neo4j.gds.walking; +package org.neo4j.gds.procedures.algorithms.miscellaneous; +import org.neo4j.gds.applications.algorithms.machinery.AlgorithmProcessingTimings; import org.neo4j.gds.result.AbstractResultBuilder; import java.util.Map; -@SuppressWarnings("unused") -public class MutateResult { +public class CollapsePathMutateResult { public final long preProcessingMillis; public final long computeMillis; public final long mutateMillis; @@ -32,7 +32,7 @@ public class MutateResult { public final Map configuration; - MutateResult( + public CollapsePathMutateResult( long preProcessingMillis, long computeMillis, long mutateMillis, @@ -46,11 +46,23 @@ public class MutateResult { this.configuration = configuration; } - static final class Builder extends AbstractResultBuilder { + public static CollapsePathMutateResult emptyFrom( + AlgorithmProcessingTimings timings, + Map configurationMap + ) { + return new CollapsePathMutateResult( + timings.preProcessingMillis, + timings.computeMillis, + timings.mutateOrWriteMillis, + 0, + configurationMap + ); + } + public static final class Builder extends AbstractResultBuilder { @Override - public MutateResult build() { - return new MutateResult( + public CollapsePathMutateResult build() { + return new CollapsePathMutateResult( preProcessingMillis, computeMillis, mutateMillis, diff --git a/procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/MiscellaneousProcedureFacade.java b/procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/MiscellaneousProcedureFacade.java index 019bc03cad..2e961d299e 100644 --- a/procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/MiscellaneousProcedureFacade.java +++ b/procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/MiscellaneousProcedureFacade.java @@ -26,6 +26,7 @@ import org.neo4j.gds.applications.algorithms.miscellaneous.MiscellaneousApplicationsStatsModeBusinessFacade; import org.neo4j.gds.applications.algorithms.miscellaneous.MiscellaneousApplicationsStreamModeBusinessFacade; import org.neo4j.gds.applications.algorithms.miscellaneous.MiscellaneousApplicationsWriteModeBusinessFacade; +import org.neo4j.gds.procedures.algorithms.miscellaneous.stubs.CollapsePathMutateStub; import org.neo4j.gds.procedures.algorithms.miscellaneous.stubs.ScalePropertiesMutateStub; import org.neo4j.gds.procedures.algorithms.runners.AlgorithmExecutionScaffolding; import org.neo4j.gds.procedures.algorithms.runners.EstimationModeRunner; @@ -42,6 +43,7 @@ public final class MiscellaneousProcedureFacade { private final ProcedureReturnColumns procedureReturnColumns; private final ScalePropertiesMutateStub alphaScalePropertiesMutateStub; + private final CollapsePathMutateStub collapsePathMutateStub; private final ScalePropertiesMutateStub scalePropertiesMutateStub; private final ApplicationsFacade applicationsFacade; @@ -53,6 +55,7 @@ public final class MiscellaneousProcedureFacade { private MiscellaneousProcedureFacade( ProcedureReturnColumns procedureReturnColumns, ScalePropertiesMutateStub alphaScalePropertiesMutateStub, + CollapsePathMutateStub collapsePathMutateStub, ScalePropertiesMutateStub scalePropertiesMutateStub, ApplicationsFacade applicationsFacade, EstimationModeRunner estimationMode, @@ -61,6 +64,7 @@ private MiscellaneousProcedureFacade( ) { this.procedureReturnColumns = procedureReturnColumns; this.alphaScalePropertiesMutateStub = alphaScalePropertiesMutateStub; + this.collapsePathMutateStub = collapsePathMutateStub; this.scalePropertiesMutateStub = scalePropertiesMutateStub; this.applicationsFacade = applicationsFacade; this.estimationMode = estimationMode; @@ -82,6 +86,7 @@ public static MiscellaneousProcedureFacade create( procedureReturnColumns, true ); + var collapsePathMutateStub = new CollapsePathMutateStub(genericStub, applicationsFacade); var scalePropertiesMutateStub = new ScalePropertiesMutateStub( genericStub, applicationsFacade, @@ -92,6 +97,7 @@ public static MiscellaneousProcedureFacade create( return new MiscellaneousProcedureFacade( procedureReturnColumns, alphaScalePropertiesMutateStub, + collapsePathMutateStub, scalePropertiesMutateStub, applicationsFacade, estimationModeRunner, @@ -120,6 +126,10 @@ public Stream alphaScalePropertiesStream( ); } + public CollapsePathMutateStub collapsePathMutateStub() { + return collapsePathMutateStub; + } + public ScalePropertiesMutateStub scalePropertiesMutateStub() { return scalePropertiesMutateStub; } diff --git a/procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/stubs/CollapsePathMutateStub.java b/procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/stubs/CollapsePathMutateStub.java new file mode 100644 index 0000000000..df489854a2 --- /dev/null +++ b/procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/stubs/CollapsePathMutateStub.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) "Neo4j" + * Neo4j Sweden AB [http://neo4j.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.neo4j.gds.procedures.algorithms.miscellaneous.stubs; + +import org.neo4j.gds.applications.ApplicationsFacade; +import org.neo4j.gds.applications.algorithms.machinery.MemoryEstimateResult; +import org.neo4j.gds.applications.algorithms.miscellaneous.MiscellaneousApplicationsEstimationModeBusinessFacade; +import org.neo4j.gds.mem.MemoryEstimation; +import org.neo4j.gds.procedures.algorithms.miscellaneous.CollapsePathMutateResult; +import org.neo4j.gds.procedures.algorithms.stubs.GenericStub; +import org.neo4j.gds.procedures.algorithms.stubs.MutateStub; +import org.neo4j.gds.walking.CollapsePathConfig; + +import java.util.Map; +import java.util.stream.Stream; + +public class CollapsePathMutateStub implements MutateStub { + private final GenericStub genericStub; + private final ApplicationsFacade applicationsFacade; + + public CollapsePathMutateStub(GenericStub genericStub, ApplicationsFacade applicationsFacade) { + this.genericStub = genericStub; + this.applicationsFacade = applicationsFacade; + } + + @Override + public CollapsePathConfig parseConfiguration(Map configuration) { + return genericStub.parseConfiguration(CollapsePathConfig::of, configuration); + } + + @Override + public MemoryEstimation getMemoryEstimation(String username, Map rawConfiguration) { + return genericStub.getMemoryEstimation( + username, + rawConfiguration, + CollapsePathConfig::of, + __ -> estimationMode().collapsePath() + ); + } + + @Override + public Stream estimate(Object graphNameAsString, Map rawConfiguration) { + return genericStub.estimate( + graphNameAsString, + rawConfiguration, + CollapsePathConfig::of, + __ -> estimationMode().collapsePath() + ); + } + + @Override + public Stream execute( + String graphNameAsString, + Map rawConfiguration + ) { + var resultBuilder = new CollapsePathResultBuilderForMutateMode(); + + return genericStub.execute( + graphNameAsString, + rawConfiguration, + CollapsePathConfig::of, + applicationsFacade.miscellaneous().mutate()::collapsePath, + resultBuilder + ); + } + + private MiscellaneousApplicationsEstimationModeBusinessFacade estimationMode() { + return applicationsFacade.miscellaneous().estimate(); + } +} diff --git a/procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/stubs/CollapsePathResultBuilderForMutateMode.java b/procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/stubs/CollapsePathResultBuilderForMutateMode.java new file mode 100644 index 0000000000..a8b54ad350 --- /dev/null +++ b/procedures/algorithms-facade/src/main/java/org/neo4j/gds/procedures/algorithms/miscellaneous/stubs/CollapsePathResultBuilderForMutateMode.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) "Neo4j" + * Neo4j Sweden AB [http://neo4j.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.neo4j.gds.procedures.algorithms.miscellaneous.stubs; + +import org.neo4j.gds.api.Graph; +import org.neo4j.gds.api.GraphStore; +import org.neo4j.gds.applications.algorithms.machinery.AlgorithmProcessingTimings; +import org.neo4j.gds.applications.algorithms.machinery.ResultBuilder; +import org.neo4j.gds.core.loading.SingleTypeRelationships; +import org.neo4j.gds.procedures.algorithms.miscellaneous.CollapsePathMutateResult; +import org.neo4j.gds.walking.CollapsePathConfig; + +import java.util.Optional; + +class CollapsePathResultBuilderForMutateMode implements ResultBuilder { + @Override + public CollapsePathMutateResult build( + Graph graph, + GraphStore graphStore, + CollapsePathConfig configuration, + Optional result, + AlgorithmProcessingTimings timings, + Optional metadata + ) { + if (result.isEmpty()) return CollapsePathMutateResult.emptyFrom(timings, configuration.toMap()); + + var singleTypeRelationships = result.get(); + + return new CollapsePathMutateResult( + timings.preProcessingMillis, + timings.computeMillis, + timings.mutateOrWriteMillis, + singleTypeRelationships.topology().elementCount(), + configuration.toMap() + ); + } +}