From c2161eaca872f32016af0a928dec1e45dc703664 Mon Sep 17 00:00:00 2001 From: Lasse Westh-Nielsen Date: Mon, 25 Nov 2024 15:36:36 +0100 Subject: [PATCH] kill all shortest path specs and factories (see what i did there?) --- .../gds/paths/delta/DeltaSteppingFactory.java | 64 ------------ .../gds/paths/dijkstra/DijkstraFactory.java | 67 ------------- .../gds/paths/delta/DeltaSteppingTest.java | 63 ++++++------ .../AllShortestPathsStreamSpec.java | 98 ------------------- .../org/neo4j/gds/allshortest/Constants.java | 26 ----- .../AllShortestPathsDeltaMutateSpec.java | 65 ------------ .../delta/AllShortestPathsDeltaStatsSpec.java | 65 ------------ .../AllShortestPathsDeltaStreamSpec.java | 65 ------------ .../delta/AllShortestPathsDeltaWriteSpec.java | 64 ------------ .../java/org/neo4j/gds/delta/Constants.java | 29 ------ .../AllShortestPathsDijkstraMutateSpec.java | 67 ------------- .../AllShortestPathsDijkstraStreamSpec.java | 67 ------------- .../AllShortestPathsDijkstraWriteSpec.java | 67 ------------- .../org/neo4j/gds/djikstra/Constants.java | 24 ----- .../pathfinding/PathFindingAlgorithms.java | 2 +- 15 files changed, 30 insertions(+), 803 deletions(-) delete mode 100644 algo/src/main/java/org/neo4j/gds/paths/delta/DeltaSteppingFactory.java delete mode 100644 algo/src/main/java/org/neo4j/gds/paths/dijkstra/DijkstraFactory.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/allshortest/AllShortestPathsStreamSpec.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/allshortest/Constants.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaMutateSpec.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaStatsSpec.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaStreamSpec.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaWriteSpec.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/delta/Constants.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/AllShortestPathsDijkstraMutateSpec.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/AllShortestPathsDijkstraStreamSpec.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/AllShortestPathsDijkstraWriteSpec.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/Constants.java diff --git a/algo/src/main/java/org/neo4j/gds/paths/delta/DeltaSteppingFactory.java b/algo/src/main/java/org/neo4j/gds/paths/delta/DeltaSteppingFactory.java deleted file mode 100644 index 399b70c428..0000000000 --- a/algo/src/main/java/org/neo4j/gds/paths/delta/DeltaSteppingFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.paths.delta; - -import org.neo4j.gds.GraphAlgorithmFactory; -import org.neo4j.gds.api.Graph; -import org.neo4j.gds.core.concurrency.DefaultPool; -import org.neo4j.gds.mem.MemoryEstimation; -import org.neo4j.gds.core.utils.progress.tasks.ProgressTracker; -import org.neo4j.gds.core.utils.progress.tasks.Task; -import org.neo4j.gds.core.utils.progress.tasks.Tasks; -import org.neo4j.gds.paths.delta.config.AllShortestPathsDeltaBaseConfig; - -import java.util.List; - -public class DeltaSteppingFactory extends GraphAlgorithmFactory { - - @Override - public DeltaStepping build( - Graph graph, - T configuration, - ProgressTracker progressTracker - ) { - return DeltaStepping.of(graph, configuration, DefaultPool.INSTANCE, progressTracker); - } - - @Override - public String taskName() { - return "DeltaStepping"; - } - - @Override - public Task progressTask(Graph graphOrGraphStore, AllShortestPathsDeltaBaseConfig config) { - return Tasks.iterativeOpen( - taskName(), - () -> List.of( - Tasks.leaf(DeltaStepping.Phase.RELAX.name()), - Tasks.leaf(DeltaStepping.Phase.SYNC.name()) - ) - ); - } - - @Override - public MemoryEstimation memoryEstimation(T configuration) { - return new DeltaSteppingMemoryEstimateDefinition().memoryEstimation(); - } -} diff --git a/algo/src/main/java/org/neo4j/gds/paths/dijkstra/DijkstraFactory.java b/algo/src/main/java/org/neo4j/gds/paths/dijkstra/DijkstraFactory.java deleted file mode 100644 index 97598e50ae..0000000000 --- a/algo/src/main/java/org/neo4j/gds/paths/dijkstra/DijkstraFactory.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.paths.dijkstra; - -import org.neo4j.gds.GraphAlgorithmFactory; -import org.neo4j.gds.api.Graph; -import org.neo4j.gds.mem.MemoryEstimation; -import org.neo4j.gds.core.utils.progress.tasks.ProgressTracker; -import org.neo4j.gds.core.utils.progress.tasks.Task; -import org.neo4j.gds.core.utils.progress.tasks.Tasks; -import org.neo4j.gds.paths.dijkstra.config.DijkstraBaseConfig; -import org.neo4j.gds.termination.TerminationFlag; - -import java.util.Optional; - -public abstract class DijkstraFactory extends GraphAlgorithmFactory { - - @Override - public MemoryEstimation memoryEstimation(CONFIG configuration) { - return new DijkstraMemoryEstimateDefinition(configuration.toMemoryEstimateParameters()).memoryEstimation(); - } - - @Override - public String taskName() { - return "Dijkstra"; - } - - @Override - public Task progressTask(Graph graph, CONFIG config) { - return Tasks.leaf(taskName(), graph.relationshipCount()); - } - - public static class AllShortestPathsDijkstraFactory extends DijkstraFactory { - @Override - public Dijkstra build( - Graph graph, - T configuration, - ProgressTracker progressTracker - ) { - return Dijkstra.singleSource( - graph, - configuration.sourceNode(), - false, - Optional.empty(), - progressTracker, - TerminationFlag.RUNNING_TRUE - ); - } - } -} diff --git a/algo/src/test/java/org/neo4j/gds/paths/delta/DeltaSteppingTest.java b/algo/src/test/java/org/neo4j/gds/paths/delta/DeltaSteppingTest.java index ec668e5566..54204abcd6 100644 --- a/algo/src/test/java/org/neo4j/gds/paths/delta/DeltaSteppingTest.java +++ b/algo/src/test/java/org/neo4j/gds/paths/delta/DeltaSteppingTest.java @@ -27,17 +27,19 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import org.neo4j.gds.TestProgressTracker; import org.neo4j.gds.TestSupport; import org.neo4j.gds.api.Graph; import org.neo4j.gds.api.schema.Direction; +import org.neo4j.gds.applications.algorithms.machinery.ProgressTrackerCreator; +import org.neo4j.gds.applications.algorithms.machinery.RequestScopedDependencies; +import org.neo4j.gds.applications.algorithms.pathfinding.PathFindingAlgorithms; import org.neo4j.gds.beta.generator.PropertyProducer; import org.neo4j.gds.beta.generator.RandomGraphGeneratorBuilder; import org.neo4j.gds.beta.generator.RelationshipDistribution; -import org.neo4j.gds.core.concurrency.Concurrency; import org.neo4j.gds.core.concurrency.DefaultPool; import org.neo4j.gds.core.utils.progress.EmptyTaskRegistryFactory; import org.neo4j.gds.core.utils.progress.tasks.ProgressTracker; +import org.neo4j.gds.core.utils.warnings.EmptyUserLogRegistryFactory; import org.neo4j.gds.extension.GdlExtension; import org.neo4j.gds.extension.GdlGraph; import org.neo4j.gds.extension.IdFunction; @@ -48,16 +50,13 @@ import org.neo4j.gds.paths.dijkstra.Dijkstra; import org.neo4j.gds.termination.TerminationFlag; -import java.util.List; import java.util.Optional; import java.util.Set; -import java.util.concurrent.atomic.AtomicLong; import java.util.stream.DoubleStream; import java.util.stream.IntStream; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; import static org.neo4j.gds.assertj.Extractors.removingThreadId; import static org.neo4j.gds.compat.TestLog.INFO; import static org.neo4j.gds.paths.PathTestUtil.expected; @@ -179,49 +178,45 @@ void singleSourceFromDisconnectedNode(double delta, int concurrency, long idOffs @Test void shouldLogProgress() { + var log = new GdsTestLog(); + var requestScopedDependencies = RequestScopedDependencies.builder() + .with(EmptyTaskRegistryFactory.INSTANCE) + .with(TerminationFlag.RUNNING_TRUE) + .with(EmptyUserLogRegistryFactory.INSTANCE) + .build(); + var progressTrackerCreator = new ProgressTrackerCreator(log, requestScopedDependencies); + var pathFindingAlgorithms = new PathFindingAlgorithms(requestScopedDependencies, progressTrackerCreator); + var config = AllShortestPathsDeltaStreamConfigImpl.builder() .concurrency(4) .sourceNode(idFunction.of("c")) .delta(5) .build(); + pathFindingAlgorithms.deltaStepping(graph, config).pathSet(); - var progressTask = new DeltaSteppingFactory<>().progressTask(graph, config); - var testLog = new GdsTestLog(); - var progressTracker = new TestProgressTracker(progressTask, testLog, new Concurrency(1), EmptyTaskRegistryFactory.INSTANCE); - - DeltaStepping.of(graph, config, DefaultPool.INSTANCE, progressTracker) - .compute() - .pathSet(); - - List progresses = progressTracker.getProgresses(); - assertEquals(7, progresses.size()); - - var messagesInOrder = testLog.getMessages(INFO); - - assertThat(messagesInOrder) + assertThat(log.getMessages(INFO)) // avoid asserting on the thread id .extracting(removingThreadId()) .hasSize(20) .containsSequence( - "DeltaStepping :: Start", - "DeltaStepping :: RELAX 1 :: Start", - "DeltaStepping :: RELAX 1 100%", - "DeltaStepping :: RELAX 1 :: Finished", - "DeltaStepping :: SYNC 1 :: Start", - "DeltaStepping :: SYNC 1 100%", - "DeltaStepping :: SYNC 1 :: Finished" + "Delta Stepping :: Start", + "Delta Stepping :: RELAX 1 :: Start", + "Delta Stepping :: RELAX 1 100%", + "Delta Stepping :: RELAX 1 :: Finished", + "Delta Stepping :: SYNC 1 :: Start", + "Delta Stepping :: SYNC 1 100%", + "Delta Stepping :: SYNC 1 :: Finished" ) .containsSequence( - "DeltaStepping :: RELAX 3 :: Start", - "DeltaStepping :: RELAX 3 100%", - "DeltaStepping :: RELAX 3 :: Finished", - "DeltaStepping :: SYNC 3 :: Start", - "DeltaStepping :: SYNC 3 100%", - "DeltaStepping :: SYNC 3 :: Finished", - "DeltaStepping :: Finished" + "Delta Stepping :: RELAX 3 :: Start", + "Delta Stepping :: RELAX 3 100%", + "Delta Stepping :: RELAX 3 :: Finished", + "Delta Stepping :: SYNC 3 :: Start", + "Delta Stepping :: SYNC 3 100%", + "Delta Stepping :: SYNC 3 :: Finished", + "Delta Stepping :: Finished" ); } - } @Nested diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/allshortest/AllShortestPathsStreamSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/allshortest/AllShortestPathsStreamSpec.java deleted file mode 100644 index 5ed267d803..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/allshortest/AllShortestPathsStreamSpec.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.allshortest; - -import org.neo4j.gds.AlgorithmFactory; -import org.neo4j.gds.GraphAlgorithmFactory; -import org.neo4j.gds.NullComputationResultConsumer; -import org.neo4j.gds.allshortestpaths.AllShortestPathsConfig; -import org.neo4j.gds.allshortestpaths.AllShortestPathsStreamResult; -import org.neo4j.gds.allshortestpaths.MSBFSASPAlgorithm; -import org.neo4j.gds.allshortestpaths.MSBFSAllShortestPaths; -import org.neo4j.gds.allshortestpaths.WeightedAllShortestPaths; -import org.neo4j.gds.api.Graph; -import org.neo4j.gds.core.concurrency.DefaultPool; -import org.neo4j.gds.core.utils.progress.tasks.ProgressTracker; -import org.neo4j.gds.executor.AlgorithmSpec; -import org.neo4j.gds.executor.ComputationResultConsumer; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.GdsCallable; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; -import org.neo4j.gds.termination.TerminationFlag; - -import java.util.stream.Stream; - -import static org.neo4j.gds.executor.ExecutionMode.STREAM; - -@GdsCallable( - name = "gds.allShortestPaths.stream", - aliases = "gds.alpha.allShortestPaths.stream", - description = Constants.ALL_PAIRS_SHORTEST_PATH_DESCRIPTION, - executionMode = STREAM -) -public class AllShortestPathsStreamSpec implements AlgorithmSpec, AllShortestPathsConfig, Stream, AlgorithmFactory> { - @Override - public String name() { - return "AllShortestPathsStream"; - } - - @Override - public AlgorithmFactory algorithmFactory(ExecutionContext executionContext) { - return new GraphAlgorithmFactory<>() { - @Override - public String taskName() { - return "MSBFSASPAlgorithm"; - } - - @Override - public MSBFSASPAlgorithm build( - Graph graph, - AllShortestPathsConfig configuration, - ProgressTracker progressTracker - ) { - if (configuration.hasRelationshipWeightProperty()) { - return new WeightedAllShortestPaths( - graph, - DefaultPool.INSTANCE, - configuration.concurrency(), - TerminationFlag.RUNNING_TRUE - ); - } else { - return new MSBFSAllShortestPaths( - graph, - configuration.concurrency(), - DefaultPool.INSTANCE, - TerminationFlag.RUNNING_TRUE - ); - } - } - }; - } - - @Override - public NewConfigFunction newConfigFunction() { - return AllShortestPathsConfig::of; - } - - @Override - public ComputationResultConsumer, AllShortestPathsConfig, Stream> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/allshortest/Constants.java b/algorithm-specifications/src/main/java/org/neo4j/gds/allshortest/Constants.java deleted file mode 100644 index 4ce81b898f..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/allshortest/Constants.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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.allshortest; - -final class Constants { - static final String ALL_PAIRS_SHORTEST_PATH_DESCRIPTION = "The All Pairs Shortest Path (APSP) calculates the shortest (weighted) path between all pairs of nodes."; - - private Constants() {} -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaMutateSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaMutateSpec.java deleted file mode 100644 index d9196991f4..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaMutateSpec.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.delta; - -import org.neo4j.gds.NullComputationResultConsumer; -import org.neo4j.gds.executor.AlgorithmSpec; -import org.neo4j.gds.executor.ComputationResultConsumer; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.GdsCallable; -import org.neo4j.gds.paths.delta.DeltaStepping; -import org.neo4j.gds.paths.delta.DeltaSteppingFactory; -import org.neo4j.gds.paths.delta.config.AllShortestPathsDeltaMutateConfig; -import org.neo4j.gds.paths.dijkstra.PathFindingResult; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; -import org.neo4j.gds.procedures.algorithms.pathfinding.PathFindingMutateResult; - -import java.util.stream.Stream; - -import static org.neo4j.gds.executor.ExecutionMode.MUTATE_RELATIONSHIP; - -@GdsCallable(name = "gds.allShortestPaths.delta.mutate", description = Constants.DELTA_STEPPING_DESCRIPTION, executionMode = MUTATE_RELATIONSHIP) -public class AllShortestPathsDeltaMutateSpec implements AlgorithmSpec, DeltaSteppingFactory> { - - @Override - public String name() { - return "gds.allShortestPaths.delta.mutate"; - } - - @Override - public DeltaSteppingFactory algorithmFactory(ExecutionContext executionContext) { - return new DeltaSteppingFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (username, configuration) -> AllShortestPathsDeltaMutateConfig.of(configuration); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } - -@Override - public boolean releaseProgressTask() { - return false; - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaStatsSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaStatsSpec.java deleted file mode 100644 index 896da843f8..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaStatsSpec.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.delta; - -import org.neo4j.gds.NullComputationResultConsumer; -import org.neo4j.gds.executor.AlgorithmSpec; -import org.neo4j.gds.executor.ComputationResultConsumer; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.GdsCallable; -import org.neo4j.gds.paths.delta.DeltaStepping; -import org.neo4j.gds.paths.delta.DeltaSteppingFactory; -import org.neo4j.gds.paths.delta.config.AllShortestPathsDeltaStatsConfig; -import org.neo4j.gds.paths.dijkstra.PathFindingResult; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; -import org.neo4j.gds.procedures.algorithms.results.StandardStatsResult; - -import java.util.stream.Stream; - -import static org.neo4j.gds.executor.ExecutionMode.STATS; - -@GdsCallable(name = "gds.allShortestPaths.delta.stats", description = Constants.DELTA_STEPPING_DESCRIPTION, executionMode = STATS) -public class AllShortestPathsDeltaStatsSpec implements AlgorithmSpec, DeltaSteppingFactory> { - - @Override - public String name() { - return "gds.allShortestPaths.delta.stats"; - } - - @Override - public DeltaSteppingFactory algorithmFactory(ExecutionContext executionContext) { - return new DeltaSteppingFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (username, configuration) -> AllShortestPathsDeltaStatsConfig.of(configuration); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } - - @Override - public boolean releaseProgressTask() { - return false; - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaStreamSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaStreamSpec.java deleted file mode 100644 index dfaca44d21..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaStreamSpec.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.delta; - -import org.neo4j.gds.NullComputationResultConsumer; -import org.neo4j.gds.executor.AlgorithmSpec; -import org.neo4j.gds.executor.ComputationResultConsumer; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.GdsCallable; -import org.neo4j.gds.paths.delta.DeltaStepping; -import org.neo4j.gds.paths.delta.DeltaSteppingFactory; -import org.neo4j.gds.paths.delta.config.AllShortestPathsDeltaStreamConfig; -import org.neo4j.gds.paths.dijkstra.PathFindingResult; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; -import org.neo4j.gds.procedures.algorithms.pathfinding.PathFindingStreamResult; - -import java.util.stream.Stream; - -import static org.neo4j.gds.executor.ExecutionMode.STREAM; - -@GdsCallable(name = "gds.allShortestPaths.delta.stream", description = Constants.DELTA_STEPPING_DESCRIPTION, executionMode = STREAM) -public class AllShortestPathsDeltaStreamSpec implements AlgorithmSpec, DeltaSteppingFactory> { - - @Override - public String name() { - return "gds.allShortestPaths.delta.stream"; - } - - @Override - public DeltaSteppingFactory algorithmFactory(ExecutionContext executionContext) { - return new DeltaSteppingFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (username, configuration) -> AllShortestPathsDeltaStreamConfig.of(configuration); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } - - @Override - public boolean releaseProgressTask() { - return false; - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaWriteSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaWriteSpec.java deleted file mode 100644 index b3dafa5aff..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/delta/AllShortestPathsDeltaWriteSpec.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.delta; - -import org.neo4j.gds.NullComputationResultConsumer; -import org.neo4j.gds.executor.AlgorithmSpec; -import org.neo4j.gds.executor.ComputationResultConsumer; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.GdsCallable; -import org.neo4j.gds.paths.delta.DeltaStepping; -import org.neo4j.gds.paths.delta.DeltaSteppingFactory; -import org.neo4j.gds.paths.delta.config.AllShortestPathsDeltaWriteConfig; -import org.neo4j.gds.paths.dijkstra.PathFindingResult; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; -import org.neo4j.gds.procedures.algorithms.results.StandardWriteRelationshipsResult; - -import java.util.stream.Stream; - -import static org.neo4j.gds.executor.ExecutionMode.WRITE_RELATIONSHIP; - -@GdsCallable(name = "gds.allShortestPaths.delta.write", description = Constants.DELTA_STEPPING_DESCRIPTION, executionMode = WRITE_RELATIONSHIP) -public class AllShortestPathsDeltaWriteSpec implements AlgorithmSpec, DeltaSteppingFactory> { - @Override - public String name() { - return "gds.allShortestPaths.delta.write"; - } - - @Override - public DeltaSteppingFactory algorithmFactory(ExecutionContext executionContext) { - return new DeltaSteppingFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (username, configuration) -> AllShortestPathsDeltaWriteConfig.of(configuration); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } - - @Override - public boolean releaseProgressTask() { - return false; - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/delta/Constants.java b/algorithm-specifications/src/main/java/org/neo4j/gds/delta/Constants.java deleted file mode 100644 index 241a0e5ffd..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/delta/Constants.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.delta; - -final class Constants { - - static final String DELTA_STEPPING_DESCRIPTION = "The Delta Stepping shortest path algorithm computes the shortest (weighted) path between one node and any other node in the graph. " + - "The computation is run multi-threaded"; - - private Constants() {} - -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/AllShortestPathsDijkstraMutateSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/AllShortestPathsDijkstraMutateSpec.java deleted file mode 100644 index 71e5630f0f..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/AllShortestPathsDijkstraMutateSpec.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.djikstra; - -import org.neo4j.gds.NullComputationResultConsumer; -import org.neo4j.gds.executor.AlgorithmSpec; -import org.neo4j.gds.executor.ComputationResultConsumer; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.GdsCallable; -import org.neo4j.gds.paths.dijkstra.Dijkstra; -import org.neo4j.gds.paths.dijkstra.DijkstraFactory; -import org.neo4j.gds.paths.dijkstra.PathFindingResult; -import org.neo4j.gds.paths.dijkstra.config.AllShortestPathsDijkstraMutateConfig; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; -import org.neo4j.gds.procedures.algorithms.pathfinding.PathFindingMutateResult; - -import java.util.stream.Stream; - -import static org.neo4j.gds.executor.ExecutionMode.MUTATE_RELATIONSHIP; - -@GdsCallable(name = "gds.allShortestPaths.dijkstra.mutate", description = Constants.SINGLE_SOURCE_DIJKSTRA_DESCRIPTION, executionMode = MUTATE_RELATIONSHIP) -public class AllShortestPathsDijkstraMutateSpec implements AlgorithmSpec, DijkstraFactory.AllShortestPathsDijkstraFactory> { - - @Override - public String name() { - return "gds.allShortestPaths.dijkstra.mutate"; - } - - @Override - public DijkstraFactory.AllShortestPathsDijkstraFactory algorithmFactory( - ExecutionContext executionContext - ) { - return new DijkstraFactory.AllShortestPathsDijkstraFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (username, configuration) -> AllShortestPathsDijkstraMutateConfig.of(configuration); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } - -@Override - public boolean releaseProgressTask() { - return false; - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/AllShortestPathsDijkstraStreamSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/AllShortestPathsDijkstraStreamSpec.java deleted file mode 100644 index f17b450819..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/AllShortestPathsDijkstraStreamSpec.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.djikstra; - -import org.neo4j.gds.NullComputationResultConsumer; -import org.neo4j.gds.executor.AlgorithmSpec; -import org.neo4j.gds.executor.ComputationResultConsumer; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.GdsCallable; -import org.neo4j.gds.paths.dijkstra.Dijkstra; -import org.neo4j.gds.paths.dijkstra.DijkstraFactory; -import org.neo4j.gds.paths.dijkstra.PathFindingResult; -import org.neo4j.gds.paths.dijkstra.config.AllShortestPathsDijkstraStreamConfig; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; -import org.neo4j.gds.procedures.algorithms.pathfinding.PathFindingStreamResult; - -import java.util.stream.Stream; - -import static org.neo4j.gds.executor.ExecutionMode.MUTATE_RELATIONSHIP; - -@GdsCallable(name = "gds.allShortestPaths.dijkstra.stream", description = Constants.SINGLE_SOURCE_DIJKSTRA_DESCRIPTION, executionMode = MUTATE_RELATIONSHIP) -public class AllShortestPathsDijkstraStreamSpec implements AlgorithmSpec, DijkstraFactory.AllShortestPathsDijkstraFactory> { - - @Override - public String name() { - return "gds.allShortestPaths.dijkstra.stream"; - } - - @Override - public DijkstraFactory.AllShortestPathsDijkstraFactory algorithmFactory( - ExecutionContext executionContext - ) { - return new DijkstraFactory.AllShortestPathsDijkstraFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (username, configuration) -> AllShortestPathsDijkstraStreamConfig.of(configuration); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } - - @Override - public boolean releaseProgressTask() { - return false; - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/AllShortestPathsDijkstraWriteSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/AllShortestPathsDijkstraWriteSpec.java deleted file mode 100644 index 4a7a1288f7..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/AllShortestPathsDijkstraWriteSpec.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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.djikstra; - -import org.neo4j.gds.NullComputationResultConsumer; -import org.neo4j.gds.executor.AlgorithmSpec; -import org.neo4j.gds.executor.ComputationResultConsumer; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.GdsCallable; -import org.neo4j.gds.paths.dijkstra.Dijkstra; -import org.neo4j.gds.paths.dijkstra.DijkstraFactory; -import org.neo4j.gds.paths.dijkstra.PathFindingResult; -import org.neo4j.gds.paths.dijkstra.config.AllShortestPathsDijkstraWriteConfig; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; -import org.neo4j.gds.procedures.algorithms.results.StandardWriteRelationshipsResult; - -import java.util.stream.Stream; - -import static org.neo4j.gds.executor.ExecutionMode.WRITE_RELATIONSHIP; - -@GdsCallable(name = "gds.allShortestPaths.dijkstra.write", description = Constants.SINGLE_SOURCE_DIJKSTRA_DESCRIPTION, executionMode = WRITE_RELATIONSHIP) -public class AllShortestPathsDijkstraWriteSpec implements AlgorithmSpec, DijkstraFactory.AllShortestPathsDijkstraFactory> { - - @Override - public String name() { - return "gds.allShortestPaths.dijkstra.write"; - } - - @Override - public DijkstraFactory.AllShortestPathsDijkstraFactory algorithmFactory( - ExecutionContext executionContext - ) { - return new DijkstraFactory.AllShortestPathsDijkstraFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (username, configuration) -> AllShortestPathsDijkstraWriteConfig.of(configuration); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } - - @Override - public boolean releaseProgressTask() { - return false; - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/Constants.java b/algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/Constants.java deleted file mode 100644 index 3ffb8d2ad8..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/djikstra/Constants.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.djikstra; - -class Constants { - static final String SINGLE_SOURCE_DIJKSTRA_DESCRIPTION = "The Dijkstra shortest path algorithm computes the shortest (weighted) path between one node and any other node in the graph."; -} diff --git a/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithms.java b/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithms.java index 36fe494725..716babf1ab 100644 --- a/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithms.java +++ b/applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithms.java @@ -150,7 +150,7 @@ HugeLongArray breadthFirstSearch(Graph graph, BfsBaseConfig configuration) { ); } - PathFindingResult deltaStepping(Graph graph, AllShortestPathsDeltaBaseConfig configuration) { + public PathFindingResult deltaStepping(Graph graph, AllShortestPathsDeltaBaseConfig configuration) { var iterativeTask = Tasks.iterativeOpen( AlgorithmLabel.DeltaStepping.asString(), () -> List.of(