diff --git a/algo/src/main/java/org/neo4j/gds/scc/Scc.java b/algo/src/main/java/org/neo4j/gds/scc/Scc.java index 75f1462a54..d46e8953e7 100644 --- a/algo/src/main/java/org/neo4j/gds/scc/Scc.java +++ b/algo/src/main/java/org/neo4j/gds/scc/Scc.java @@ -34,9 +34,8 @@ * specified in: http://code.activestate.com/recipes/578507-strongly-connected-components-of-a-directed-graph/ */ public class Scc extends Algorithm { - public static final int UNORDERED = -1; - public static final String SCC_DESCRIPTION = "The SCC algorithm finds sets of connected nodes in an directed graph, " + - "where all nodes in the same set form a connected component."; + private static final int UNORDERED = -1; + private final Graph graph; private final HugeLongArrayStack boundaries; private final HugeLongArray connectedComponents; diff --git a/algo/src/main/java/org/neo4j/gds/scc/SccAlgorithmFactory.java b/algo/src/main/java/org/neo4j/gds/scc/SccAlgorithmFactory.java deleted file mode 100644 index 670cebce96..0000000000 --- a/algo/src/main/java/org/neo4j/gds/scc/SccAlgorithmFactory.java +++ /dev/null @@ -1,56 +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.scc; - -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.termination.TerminationFlag; - -public class SccAlgorithmFactory extends GraphAlgorithmFactory { - - @Override - public Scc build(Graph graph, CONFIG configuration, ProgressTracker progressTracker) { - return new Scc( - graph, - progressTracker, - TerminationFlag.RUNNING_TRUE - ); - } - - @Override - public String taskName() { - return "Scc"; - } - - @Override - public Task progressTask(Graph graph, CONFIG config) { - return Tasks.leaf(taskName(), graph.nodeCount()); - } - - @Override - public MemoryEstimation memoryEstimation(CONFIG configuration) { - - return new SccMemoryEstimateDefinition().memoryEstimation(); - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/scc/AlphaSccWriteSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/scc/AlphaSccWriteSpec.java deleted file mode 100644 index f94ce9c456..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/scc/AlphaSccWriteSpec.java +++ /dev/null @@ -1,63 +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.scc; - -import org.neo4j.gds.NullComputationResultConsumer; -import org.neo4j.gds.collections.ha.HugeLongArray; -import org.neo4j.gds.executor.AlgorithmSpec; -import org.neo4j.gds.executor.ComputationResultConsumer; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.ExecutionMode; -import org.neo4j.gds.executor.GdsCallable; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; -import org.neo4j.gds.procedures.algorithms.community.AlphaSccWriteResult; - -import java.util.stream.Stream; - -import static org.neo4j.gds.scc.Scc.SCC_DESCRIPTION; - -@GdsCallable( - name = "gds.scc.write", - aliases = {"gds.alpha.scc.write"}, - description = SCC_DESCRIPTION, - executionMode = ExecutionMode.WRITE_NODE_PROPERTY -) -public class AlphaSccWriteSpec implements AlgorithmSpec, SccAlgorithmFactory> { - - @Override - public String name() { - return "SccWrite"; - } - - @Override - public SccAlgorithmFactory algorithmFactory(ExecutionContext executionContext) { - return new SccAlgorithmFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (__, config) -> SccAlphaWriteConfig.of(config); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/scc/SccMutateSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/scc/SccMutateSpec.java deleted file mode 100644 index 9c760fce27..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/scc/SccMutateSpec.java +++ /dev/null @@ -1,62 +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.scc; - -import org.neo4j.gds.NullComputationResultConsumer; -import org.neo4j.gds.collections.ha.HugeLongArray; -import org.neo4j.gds.executor.AlgorithmSpec; -import org.neo4j.gds.executor.ComputationResultConsumer; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.ExecutionMode; -import org.neo4j.gds.executor.GdsCallable; -import org.neo4j.gds.procedures.algorithms.community.SccMutateResult; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; - -import java.util.stream.Stream; - -import static org.neo4j.gds.scc.Scc.SCC_DESCRIPTION; - -@GdsCallable( - name = "gds.scc.mutate", - description = SCC_DESCRIPTION, - executionMode = ExecutionMode.MUTATE_NODE_PROPERTY -) -public class SccMutateSpec implements AlgorithmSpec, SccAlgorithmFactory> { - - @Override - public String name() { - return "SccMutate"; - } - - @Override - public SccAlgorithmFactory algorithmFactory(ExecutionContext executionContext) { - return new SccAlgorithmFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (__, config) -> SccMutateConfig.of(config); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/scc/SccStatsSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/scc/SccStatsSpec.java deleted file mode 100644 index 7d35b27151..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/scc/SccStatsSpec.java +++ /dev/null @@ -1,58 +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.scc; - -import org.neo4j.gds.NullComputationResultConsumer; -import org.neo4j.gds.collections.ha.HugeLongArray; -import org.neo4j.gds.executor.AlgorithmSpec; -import org.neo4j.gds.executor.ComputationResultConsumer; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.ExecutionMode; -import org.neo4j.gds.executor.GdsCallable; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; -import org.neo4j.gds.procedures.algorithms.community.SccStatsResult; - -import java.util.stream.Stream; - -import static org.neo4j.gds.scc.Scc.SCC_DESCRIPTION; - -@GdsCallable(name = "gds.scc.stats", description = SCC_DESCRIPTION, executionMode = ExecutionMode.STATS) -public class SccStatsSpec implements AlgorithmSpec, SccAlgorithmFactory> { - - @Override - public String name() { - return "SccStats"; - } - - @Override - public SccAlgorithmFactory algorithmFactory(ExecutionContext executionContext) { - return new SccAlgorithmFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (__, config) -> SccStatsConfig.of(config); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/scc/SccStreamSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/scc/SccStreamSpec.java deleted file mode 100644 index f43eaa7d43..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/scc/SccStreamSpec.java +++ /dev/null @@ -1,62 +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.scc; - -import org.neo4j.gds.NullComputationResultConsumer; -import org.neo4j.gds.collections.ha.HugeLongArray; -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.procedures.algorithms.community.SccStreamResult; - -import java.util.stream.Stream; - -import static org.neo4j.gds.executor.ExecutionMode.STREAM; -import static org.neo4j.gds.scc.Scc.SCC_DESCRIPTION; - -@GdsCallable( - name = "gds.scc.stream", - aliases = {"gds.alpha.scc.stream"}, - description = SCC_DESCRIPTION, - executionMode = STREAM -) -public class SccStreamSpec implements AlgorithmSpec, SccAlgorithmFactory> { - @Override - public String name() { - return "SccStream"; - } - - @Override - public SccAlgorithmFactory algorithmFactory(ExecutionContext executionContext) { - return new SccAlgorithmFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (__, config) -> SccStreamConfig.of(config); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } -} diff --git a/algorithm-specifications/src/main/java/org/neo4j/gds/scc/SccWriteSpec.java b/algorithm-specifications/src/main/java/org/neo4j/gds/scc/SccWriteSpec.java deleted file mode 100644 index 2d0d792266..0000000000 --- a/algorithm-specifications/src/main/java/org/neo4j/gds/scc/SccWriteSpec.java +++ /dev/null @@ -1,62 +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.scc; - -import org.neo4j.gds.NullComputationResultConsumer; -import org.neo4j.gds.collections.ha.HugeLongArray; -import org.neo4j.gds.executor.AlgorithmSpec; -import org.neo4j.gds.executor.ComputationResultConsumer; -import org.neo4j.gds.executor.ExecutionContext; -import org.neo4j.gds.executor.ExecutionMode; -import org.neo4j.gds.executor.GdsCallable; -import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction; -import org.neo4j.gds.procedures.algorithms.community.SccWriteResult; - -import java.util.stream.Stream; - -import static org.neo4j.gds.scc.Scc.SCC_DESCRIPTION; - -@GdsCallable( - name = "gds.scc.write", - description = SCC_DESCRIPTION, - executionMode = ExecutionMode.WRITE_NODE_PROPERTY -) -public class SccWriteSpec implements AlgorithmSpec, SccAlgorithmFactory> { - - @Override - public String name() { - return "SccWrite"; - } - - @Override - public SccAlgorithmFactory algorithmFactory(ExecutionContext executionContext) { - return new SccAlgorithmFactory<>(); - } - - @Override - public NewConfigFunction newConfigFunction() { - return (__, config) -> SccWriteConfig.of(config); - } - - @Override - public ComputationResultConsumer> computationResultConsumer() { - return new NullComputationResultConsumer<>(); - } -} diff --git a/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithms.java b/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithms.java index c50ff9370f..6c50b5ad55 100644 --- a/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithms.java +++ b/applications/algorithms/community/src/main/java/org/neo4j/gds/applications/algorithms/community/CommunityAlgorithms.java @@ -38,6 +38,7 @@ import org.neo4j.gds.config.ConcurrencyConfig; import org.neo4j.gds.core.concurrency.DefaultPool; import org.neo4j.gds.core.utils.paged.dss.DisjointSetStruct; +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.k1coloring.K1ColoringBaseConfig; @@ -400,6 +401,10 @@ HugeLongArray scc(Graph graph, AlgoBaseConfig configuration) { Tasks.leaf(AlgorithmLabel.SCC.asString(), graph.nodeCount()) ); + return scc(graph, configuration, progressTracker); + } + + public HugeLongArray scc(Graph graph, ConcurrencyConfig configuration, ProgressTracker progressTracker) { var algorithm = new Scc(graph, progressTracker, terminationFlag); return algorithmMachinery.runAlgorithmsAndManageProgressTracker(