Skip to content

Commit 2cd2422

Browse files
committed
Add SF support for delta stepping
1 parent 1a12d86 commit 2cd2422

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed

applications/algorithms/path-finding/src/main/java/org/neo4j/gds/applications/algorithms/pathfinding/PathFindingAlgorithmsMutateModeBusinessFacade.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,30 @@ public <RESULT> RESULT singleSourceShortestPathDijkstraWithPaths(
322322
}
323323

324324

325+
public <RESULT> RESULT deltaSteppingWithPaths(
326+
GraphName graphName,
327+
AllShortestPathsDeltaMutateConfig configuration,
328+
Map<String, Stream<PathUsingInternalNodeIds>> pathStore,
329+
ResultBuilder<AllShortestPathsDeltaMutateConfig, PathFindingResult, RESULT, Void> resultBuilder
330+
) {
331+
var sideEffect = new StorePathsSideEffect(pathStore, configuration.mutateRelationshipType());
332+
333+
return algorithmProcessingTemplate.processAlgorithmAndAnySideEffects(
334+
Optional.empty(),
335+
graphName,
336+
configuration,
337+
Optional.empty(),
338+
Optional.empty(),
339+
DeltaStepping,
340+
DimensionTransformer.DISABLED,
341+
estimationFacade::deltaStepping,
342+
(graph, __) -> pathFindingAlgorithms.deltaStepping(graph, configuration),
343+
Optional.of(sideEffect),
344+
new MutateResultRenderer<>(configuration, resultBuilder)
345+
);
346+
}
347+
348+
325349
public <RESULT> RESULT spanningTree(
326350
GraphName graphName,
327351
SpanningTreeMutateConfig configuration,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Neo4j is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
package org.neo4j.gds.procedures.algorithms.pathfinding;
21+
22+
import org.neo4j.gds.api.Graph;
23+
import org.neo4j.gds.applications.algorithms.machinery.AlgorithmProcessingTimings;
24+
import org.neo4j.gds.applications.algorithms.machinery.ResultBuilder;
25+
import org.neo4j.gds.config.ToMapConvertible;
26+
import org.neo4j.gds.paths.dijkstra.PathFindingResult;
27+
28+
import java.util.Optional;
29+
30+
public class DeltaSteppingWithPathsResultBuilder<CONFIGURATION extends ToMapConvertible> implements ResultBuilder<CONFIGURATION, PathFindingResult, DeltaSteppingWithPathsResult, Void> {
31+
@Override
32+
public DeltaSteppingWithPathsResult build(
33+
Graph graph,
34+
CONFIGURATION configuration,
35+
Optional<PathFindingResult> pathFindingResult,
36+
AlgorithmProcessingTimings timings,
37+
Optional<Void> metadata
38+
) {
39+
return DeltaSteppingWithPathsResult.create(
40+
timings,
41+
configuration.toMap()
42+
);
43+
}
44+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Neo4j is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
package org.neo4j.gds.procedures.algorithms.pathfinding;
21+
22+
import org.neo4j.gds.applications.algorithms.machinery.AlgorithmProcessingTimings;
23+
import org.neo4j.gds.procedures.algorithms.results.MutateResult;
24+
25+
import java.util.Map;
26+
27+
public record DeltaSteppingWithPathsResult(long preProcessingMillis, long computeMillis, long mutateMillis,
28+
long postProcessingMillis, Map<String, Object> configuration) implements
29+
MutateResult {
30+
31+
public static DeltaSteppingWithPathsResult create(
32+
AlgorithmProcessingTimings timings,
33+
Map<String, Object> configuration
34+
) {
35+
return new DeltaSteppingWithPathsResult(
36+
timings.preProcessingMillis,
37+
timings.computeMillis,
38+
timings.sideEffectMillis,
39+
0L,
40+
configuration
41+
);
42+
}
43+
}

0 commit comments

Comments
 (0)