From 43e17b5a37612dad3b4606644331e78daf38b872 Mon Sep 17 00:00:00 2001 From: Lasse Westh-Nielsen Date: Mon, 25 Nov 2024 12:10:41 +0100 Subject: [PATCH] migrate Yeans and A* fix tests --- .../java/org/neo4j/gds/astar/Constants.java | 28 -------- .../astar/ShortestPathAStarMutateSpec.java | 65 ------------------- .../astar/ShortestPathAStarStreamSpec.java | 65 ------------------- .../gds/astar/ShortestPathAStarWriteSpec.java | 65 ------------------- .../java/org/neo4j/gds/yens/Constants.java | 27 -------- .../gds/yens/ShortestPathYensMutateSpec.java | 64 ------------------ .../gds/yens/ShortestPathYensStreamSpec.java | 65 ------------------- .../gds/yens/ShortestPathYensWriteSpec.java | 64 ------------------ 8 files changed, 443 deletions(-) delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/astar/Constants.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/astar/ShortestPathAStarMutateSpec.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/astar/ShortestPathAStarStreamSpec.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/astar/ShortestPathAStarWriteSpec.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/yens/Constants.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/yens/ShortestPathYensMutateSpec.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/yens/ShortestPathYensStreamSpec.java delete mode 100644 algorithm-specifications/src/main/java/org/neo4j/gds/yens/ShortestPathYensWriteSpec.java diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/astar/Constants.java b/algorithm-specifications/src/main/java/org/neo4j/gds/astar/Constants.java deleted file mode 100644 index 13c03f2aaf..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/astar/Constants.java +++ /dev/null @@ -1,28 +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.astar; - -class Constants { - static final String ASTAR_DESCRIPTION = - "The A* shortest path algorithm computes the shortest path between a pair of nodes. " + - "It uses the relationship weight property to compare path lengths. " + - "In addition, this implementation uses the haversine distance as a heuristic to converge faster."; - -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/astar/ShortestPathAStarMutateSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/astar/ShortestPathAStarMutateSpec.java deleted file mode 100644 index 026f5de272..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/astar/ShortestPathAStarMutateSpec.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.astar; - -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.astar.AStar; -import org.neo4j.gds.paths.astar.AStarFactory; -import org.neo4j.gds.paths.astar.config.ShortestPathAStarMutateConfig; -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.shortestPath.astar.mutate", description = Constants.ASTAR_DESCRIPTION, executionMode = MUTATE_RELATIONSHIP) -public class ShortestPathAStarMutateSpec implements AlgorithmSpec, AStarFactory> { - - @Override - public String name() { - return "AStarMutate"; - } - - @Override - public AStarFactory algorithmFactory(ExecutionContext executionContext) { - return new AStarFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (___,config) -> ShortestPathAStarMutateConfig.of(config); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } - - @Override - public boolean releaseProgressTask() { - return false; - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/astar/ShortestPathAStarStreamSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/astar/ShortestPathAStarStreamSpec.java deleted file mode 100644 index a7d23e7b8d..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/astar/ShortestPathAStarStreamSpec.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.astar; - -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.astar.AStar; -import org.neo4j.gds.paths.astar.AStarFactory; -import org.neo4j.gds.paths.astar.config.ShortestPathAStarStreamConfig; -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.shortestPath.astar.stream", description = Constants.ASTAR_DESCRIPTION, executionMode = STREAM) -public class ShortestPathAStarStreamSpec implements AlgorithmSpec, AStarFactory> { - - @Override - public String name() { - return "AStarWrite"; - } - - @Override - public AStarFactory algorithmFactory(ExecutionContext executionContext) { - return new AStarFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (___,config) -> ShortestPathAStarStreamConfig.of(config); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } - - @Override - public boolean releaseProgressTask() { - return false; - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/astar/ShortestPathAStarWriteSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/astar/ShortestPathAStarWriteSpec.java deleted file mode 100644 index 7b68e17e2a..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/astar/ShortestPathAStarWriteSpec.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.astar; - -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.astar.AStar; -import org.neo4j.gds.paths.astar.AStarFactory; -import org.neo4j.gds.paths.astar.config.ShortestPathAStarWriteConfig; -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.shortestPath.astar.write", description = Constants.ASTAR_DESCRIPTION, executionMode = WRITE_RELATIONSHIP) -public class ShortestPathAStarWriteSpec implements AlgorithmSpec, AStarFactory> { - - @Override - public String name() { - return "AStarWrite"; - } - - @Override - public AStarFactory algorithmFactory(ExecutionContext executionContext) { - return new AStarFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (___,config) -> ShortestPathAStarWriteConfig.of(config); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } - - @Override - public boolean releaseProgressTask() { - return false; - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/yens/Constants.java b/algorithm-specifications/src/main/java/org/neo4j/gds/yens/Constants.java deleted file mode 100644 index 913ec88fd8..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/yens/Constants.java +++ /dev/null @@ -1,27 +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.yens; - -class Constants { - static final String YENS_DESCRIPTION = "The Yen's shortest path algorithm computes the k shortest (weighted) paths between a pair of nodes."; - - - private Constants() {} -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/yens/ShortestPathYensMutateSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/yens/ShortestPathYensMutateSpec.java deleted file mode 100644 index 8633947b92..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/yens/ShortestPathYensMutateSpec.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.yens; - -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.PathFindingResult; -import org.neo4j.gds.paths.yens.Yens; -import org.neo4j.gds.paths.yens.YensFactory; -import org.neo4j.gds.paths.yens.config.ShortestPathYensMutateConfig; -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.shortestPath.yens.mutate", description = Constants.YENS_DESCRIPTION, executionMode = MUTATE_RELATIONSHIP) -public class ShortestPathYensMutateSpec implements AlgorithmSpec, YensFactory> { - @Override - public String name() { - return "YensMutate"; - } - - @Override - public YensFactory algorithmFactory(ExecutionContext executionContext) { - return new YensFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (___, config) -> ShortestPathYensMutateConfig.of(config); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } - - @Override - public boolean releaseProgressTask() { - return false; - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/yens/ShortestPathYensStreamSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/yens/ShortestPathYensStreamSpec.java deleted file mode 100644 index 47957491b5..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/yens/ShortestPathYensStreamSpec.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.yens; - -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.PathFindingResult; -import org.neo4j.gds.paths.yens.Yens; -import org.neo4j.gds.paths.yens.YensFactory; -import org.neo4j.gds.paths.yens.config.ShortestPathYensStreamConfig; -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.shortestPath.yens.stream", description = Constants.YENS_DESCRIPTION, executionMode = STREAM) -public class ShortestPathYensStreamSpec implements AlgorithmSpec, YensFactory> { - - @Override - public String name() { - return "YensStream"; - } - - @Override - public YensFactory algorithmFactory(ExecutionContext executionContext) { - return new YensFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (___, config) -> ShortestPathYensStreamConfig.of(config); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } - - @Override - public boolean releaseProgressTask() { - return false; - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/yens/ShortestPathYensWriteSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/yens/ShortestPathYensWriteSpec.java deleted file mode 100644 index 064480c812..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/yens/ShortestPathYensWriteSpec.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.yens; - -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.PathFindingResult; -import org.neo4j.gds.paths.yens.Yens; -import org.neo4j.gds.paths.yens.YensFactory; -import org.neo4j.gds.paths.yens.config.ShortestPathYensWriteConfig; -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.shortestPath.yens.write", description = Constants.YENS_DESCRIPTION, executionMode = WRITE_RELATIONSHIP) -public class ShortestPathYensWriteSpec implements AlgorithmSpec, YensFactory> { - @Override - public String name() { - return "YensWrite"; - } - - @Override - public YensFactory algorithmFactory(ExecutionContext executionContext) { - return new YensFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (___, config) -> ShortestPathYensWriteConfig.of(config); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } - - @Override - public boolean releaseProgressTask() { - return false; - } -}