diff --git a/algo/src/main/java/org/neo4j/gds/influenceMaximization/CELFAlgorithmFactory.java b/algo/src/main/java/org/neo4j/gds/influenceMaximization/CELFAlgorithmFactory.java deleted file mode 100644 index 1084d19876..0000000000 --- a/algo/src/main/java/org/neo4j/gds/influenceMaximization/CELFAlgorithmFactory.java +++ /dev/null @@ -1,69 +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.influenceMaximization; - -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; - -public class CELFAlgorithmFactory extends GraphAlgorithmFactory { - - @Override - public String taskName() { - return "CELF"; - } - - public CELF build( - Graph graph, - CELFParameters celfParameters, - ProgressTracker progressTracker - ) { - return new CELF(graph, celfParameters, DefaultPool.INSTANCE, progressTracker); - } - - @Override - public CELF build( - Graph graph, - CONFIG configuration, - ProgressTracker progressTracker - ) { - var parameters = configuration.toParameters(); - return build(graph, parameters, progressTracker); - } - - @Override - public Task progressTask(Graph graph, CONFIG config) { - return Tasks.task( - "CELF", - Tasks.leaf("Greedy", graph.nodeCount()), - Tasks.leaf("LazyForwarding", config.seedSetSize() - 1) - ); - } - - @Override - public MemoryEstimation memoryEstimation(CONFIG configuration) { - return new CELFMemoryEstimateDefinition(configuration.toParameters()).memoryEstimation(); - } - -} diff --git a/algo/src/test/java/org/neo4j/gds/influenceMaximization/CELFOnConnectedGraphTest.java b/algo/src/test/java/org/neo4j/gds/influenceMaximization/CELFOnConnectedGraphTest.java index b8c5ac1302..d90fdca416 100644 --- a/algo/src/test/java/org/neo4j/gds/influenceMaximization/CELFOnConnectedGraphTest.java +++ b/algo/src/test/java/org/neo4j/gds/influenceMaximization/CELFOnConnectedGraphTest.java @@ -23,18 +23,22 @@ import org.assertj.core.data.Offset; import org.junit.jupiter.api.Test; import org.neo4j.gds.Orientation; +import org.neo4j.gds.applications.algorithms.centrality.CentralityAlgorithms; +import org.neo4j.gds.applications.algorithms.machinery.ProgressTrackerCreator; +import org.neo4j.gds.applications.algorithms.machinery.RequestScopedDependencies; import org.neo4j.gds.compat.TestLog; 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.progress.tasks.TaskProgressTracker; +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; import org.neo4j.gds.extension.Inject; import org.neo4j.gds.extension.TestGraph; import org.neo4j.gds.logging.GdsTestLog; +import org.neo4j.gds.termination.TerminationFlag; import static org.assertj.core.api.Assertions.assertThat; import static org.neo4j.gds.assertj.Extractors.removingThreadId; @@ -145,17 +149,16 @@ void testSpreadWithSeed1() { @Test void shouldLogProgress() { - var config = InfluenceMaximizationStreamConfigImpl.builder().seedSetSize((int) graph.nodeCount()).build(); - - var factory = new CELFAlgorithmFactory<>(); - - var progressTask = factory.progressTask(graph, config); var log = new GdsTestLog(); - var progressTracker = new TaskProgressTracker(progressTask, log, new Concurrency(4), EmptyTaskRegistryFactory.INSTANCE); + var requestScopedDependencies = RequestScopedDependencies.builder() + .with(EmptyTaskRegistryFactory.INSTANCE) + .with(EmptyUserLogRegistryFactory.INSTANCE) + .build(); + var progressTrackerCreator = new ProgressTrackerCreator(log, requestScopedDependencies); + var centralityAlgorithms = new CentralityAlgorithms(progressTrackerCreator, TerminationFlag.RUNNING_TRUE); - factory - .build(graph, config, progressTracker) - .compute(); + var config = InfluenceMaximizationStreamConfigImpl.builder().seedSetSize((int) graph.nodeCount()).build(); + centralityAlgorithms.celf(graph, config); assertThat(log.getMessages(TestLog.INFO)) .extracting(removingThreadId()) diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/CELFMutateSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/CELFMutateSpec.java deleted file mode 100644 index 7850bb2d14..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/CELFMutateSpec.java +++ /dev/null @@ -1,60 +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.influenceMaximization; - -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.procedures.algorithms.centrality.CELFMutateResult; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; - -import java.util.stream.Stream; - -import static org.neo4j.gds.executor.ExecutionMode.MUTATE_NODE_PROPERTY; - -@GdsCallable( - name = "gds.influenceMaximization.celf.mutate", - aliases = {"gds.beta.influenceMaximization.celf.mutate"}, - description = Constants.CELF_DESCRIPTION, - executionMode = MUTATE_NODE_PROPERTY -) -public class CELFMutateSpec implements AlgorithmSpec, CELFAlgorithmFactory> { - @Override - public String name() { - return "CELFMutate"; - } - - @Override - public CELFAlgorithmFactory algorithmFactory(ExecutionContext executionContext) { - return new CELFAlgorithmFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (__, userInput) -> InfluenceMaximizationMutateConfig.of(userInput); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/CELFStatsSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/CELFStatsSpec.java deleted file mode 100644 index 1e56e1fb54..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/CELFStatsSpec.java +++ /dev/null @@ -1,60 +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.influenceMaximization; - -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.procedures.algorithms.centrality.CELFStatsResult; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; - -import java.util.stream.Stream; - -import static org.neo4j.gds.executor.ExecutionMode.STATS; - -@GdsCallable( - name = "gds.influenceMaximization.celf.stats", - aliases = {"gds.beta.influenceMaximization.celf.stats"}, - description = Constants.CELF_DESCRIPTION, - executionMode = STATS -) -public class CELFStatsSpec implements AlgorithmSpec, CELFAlgorithmFactory> { - @Override - public String name() { - return "CELFStats"; - } - - @Override - public CELFAlgorithmFactory algorithmFactory(ExecutionContext executionContext) { - return new CELFAlgorithmFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (__, userInput) -> InfluenceMaximizationStatsConfig.of(userInput); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/CELFStreamSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/CELFStreamSpec.java deleted file mode 100644 index 703658abe9..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/CELFStreamSpec.java +++ /dev/null @@ -1,61 +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.influenceMaximization; - -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.procedures.algorithms.centrality.CELFStreamResult; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; - -import java.util.stream.Stream; - -import static org.neo4j.gds.executor.ExecutionMode.STREAM; - -@GdsCallable( - name = "gds.influenceMaximization.celf.stream", - aliases = {"gds.beta.influenceMaximization.celf.stream"}, - description = Constants.CELF_DESCRIPTION, - executionMode = STREAM -) -public class CELFStreamSpec implements AlgorithmSpec, CELFAlgorithmFactory> { - - @Override - public String name() { - return "CELFStream"; - } - - @Override - public CELFAlgorithmFactory algorithmFactory(ExecutionContext executionContext) { - return new CELFAlgorithmFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (__, userInput) -> InfluenceMaximizationStreamConfig.of(userInput); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/CELFWriteSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/CELFWriteSpec.java deleted file mode 100644 index eb2418b01a..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/CELFWriteSpec.java +++ /dev/null @@ -1,60 +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.influenceMaximization; - -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.procedures.algorithms.centrality.CELFWriteResult; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; - -import java.util.stream.Stream; - -import static org.neo4j.gds.executor.ExecutionMode.WRITE_NODE_PROPERTY; - -@GdsCallable( - name = "gds.influenceMaximization.celf.write", - aliases = {"gds.beta.influenceMaximization.celf.write"}, - description = Constants.CELF_DESCRIPTION, - executionMode = WRITE_NODE_PROPERTY -) -public class CELFWriteSpec implements AlgorithmSpec, CELFAlgorithmFactory> { - @Override - public String name() { - return "CELFWrite"; - } - - @Override - public CELFAlgorithmFactory algorithmFactory(ExecutionContext executionContext) { - return new CELFAlgorithmFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (__, userInput) -> InfluenceMaximizationWriteConfig.of(userInput); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/Constants.java b/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/Constants.java deleted file mode 100644 index 476e4bfb76..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/influenceMaximization/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.influenceMaximization; - -final class Constants { - static final String CELF_DESCRIPTION = "The Cost Effective Lazy Forward (CELF) algorithm aims to find k nodes that maximize the expected spread of influence in the network."; - - private Constants() {} -} diff --git a/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithms.java b/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithms.java index a53ca3cbbe..be1aae56e0 100644 --- a/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithms.java +++ b/applications/algorithms/centrality/src/main/java/org/neo4j/gds/applications/algorithms/centrality/CentralityAlgorithms.java @@ -181,7 +181,7 @@ BridgeResult bridges(Graph graph, AlgoBaseConfig configuration) { return algorithmMachinery.runAlgorithmsAndManageProgressTracker(algorithm, progressTracker, true); } - CELFResult celf(Graph graph, InfluenceMaximizationBaseConfig configuration) { + public CELFResult celf(Graph graph, InfluenceMaximizationBaseConfig configuration) { var task = Tasks.task( AlgorithmLabel.CELF.asString(), Tasks.leaf("Greedy", graph.nodeCount()),