Skip to content

Commit 6b261a8

Browse files
Expose via local facades
sq
1 parent ebb8722 commit 6b261a8

File tree

15 files changed

+146
-16
lines changed

15 files changed

+146
-16
lines changed

algo-params/common/src/main/java/org/neo4j/gds/InputNodes.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@ public interface InputNodes {
2626
InputNodes EMPTY_INPUT_NODES = new ListInputNodes(List.of());
2727

2828
Collection<Long> inputNodes();
29+
30+
default int size(){
31+
return inputNodes().size();
32+
}
2933
}

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.neo4j.gds.config.AlgoBaseConfig;
2727
import org.neo4j.gds.exceptions.MemoryEstimationNotImplementedException;
2828
import org.neo4j.gds.maxflow.MaxFlowBaseConfig;
29+
import org.neo4j.gds.maxflow.MaxFlowMemoryEstimateDefinition;
2930
import org.neo4j.gds.mem.MemoryEstimation;
3031
import org.neo4j.gds.paths.astar.AStarMemoryEstimateDefinition;
3132
import org.neo4j.gds.paths.astar.config.ShortestPathAStarBaseConfig;
@@ -131,15 +132,20 @@ MemoryEstimation longestPath() {
131132
throw new MemoryEstimationNotImplementedException();
132133
}
133134

134-
public MemoryEstimation maxFlow() {
135-
throw new MemoryEstimationNotImplementedException();
135+
public MemoryEstimation maxFlow(MaxFlowBaseConfig configuration) {
136+
var params = configuration.toParameters();
137+
138+
var estimateDefinition = new MaxFlowMemoryEstimateDefinition(params.sourceNodes().size(),params.targetNodes().size());
139+
140+
return estimateDefinition.memoryEstimation();
136141
}
137142

138-
MemoryEstimation maxFlow(
143+
public MemoryEstimateResult maxFlow(
139144
MaxFlowBaseConfig configuration,
140145
Object graphNameOrConfiguration
141146
) {
142-
return maxFlow();
147+
var memoryEstimation= maxFlow(configuration);
148+
return runEstimation(configuration, graphNameOrConfiguration, memoryEstimation);
143149
}
144150

145151
public MemoryEstimateResult pcst(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public <RESULT> RESULT maxFlow(
201201
graphName,
202202
configuration,
203203
MaxFlow,
204-
estimationFacade::maxFlow,
204+
() -> estimationFacade.maxFlow(configuration),
205205
(graph, __) -> pathFindingAlgorithms.maxFlow(graph, configuration),
206206
mutateStep,
207207
resultBuilder

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public <RESULT> RESULT maxFlow(
119119
graphName,
120120
configuration,
121121
MaxFlow,
122-
estimationFacade::maxFlow,
122+
() -> estimationFacade.maxFlow(configuration),
123123
(graph, __) -> pathFindingAlgorithms.maxFlow(graph, configuration),
124124
resultBuilder
125125
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public <RESULT> Stream<RESULT> maxFlow(
186186
graphName,
187187
configuration,
188188
MaxFlow,
189-
estimation::maxFlow,
189+
() -> estimation.maxFlow(configuration),
190190
(graph, __) -> algorithms.maxFlow(graph, configuration),
191191
resultBuilder
192192
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public <RESULT> RESULT maxFlow(
191191
graphName,
192192
configuration,
193193
MaxFlow,
194-
estimationFacade::maxFlow,
194+
() -> estimationFacade.maxFlow(configuration),
195195
(graph, __) -> pathFindingAlgorithms.maxFlow(graph, configuration),
196196
writeStep,
197197
resultBuilder

doc/modules/ROOT/pages/operations-reference/algorithm-references.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,15 @@
227227
| `gds.louvain.stream.estimate` label:procedure[Procedure]
228228
| `gds.louvain.stats` label:procedure[Procedure]
229229
| `gds.louvain.stats.estimate` label:procedure[Procedure]
230-
.4+<.^|Max flow
230+
.8+<.^|Max Flow
231231
| `gds.maxFlow.mutate` label:procedure[Procedure]
232+
| `gds.maxFlow.mutate.estimate` label:procedure[Procedure]
232233
| `gds.maxFlow.stats` label:procedure[Procedure]
234+
| `gds.maxFlow.stats.estimate` label:procedure[Procedure]
233235
| `gds.maxFlow.stream` label:procedure[Procedure]
236+
| `gds.maxFlow.stream.estimate` label:procedure[Procedure]
234237
| `gds.maxFlow.write` label:procedure[Procedure]
238+
| `gds.maxFlow.write.estimate` label:procedure[Procedure]
235239
.4+<.^|xref:algorithms/approx-max-k-cut.adoc[Approximate Maximum k-cut]
236240
| `gds.maxkcut.mutate` label:procedure[Procedure]
237241
| `gds.maxkcut.mutate.estimate` label:procedure[Procedure]

open-packaging/src/test/java/org/neo4j/gds/OpenGdsProcedureSmokeTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,13 @@ class OpenGdsProcedureSmokeTest extends BaseProcTest {
470470
"gds.louvain.write.estimate",
471471

472472
"gds.maxFlow.mutate",
473+
"gds.maxFlow.mutate.estimate",
473474
"gds.maxFlow.stats",
475+
"gds.maxFlow.stats.estimate",
474476
"gds.maxFlow.stream",
477+
"gds.maxFlow.stream.estimate",
475478
"gds.maxFlow.write",
479+
"gds.maxFlow.write.estimate",
476480

477481
"gds.nodeSimilarity.mutate",
478482
"gds.nodeSimilarity.mutate.estimate",
@@ -634,7 +638,7 @@ void countShouldMatch() {
634638
);
635639

636640
// If you find yourself updating this count, please also update the count in SmokeTest.kt
637-
int expectedCount = 472;
641+
int expectedCount = 476;
638642
assertEquals(
639643
expectedCount,
640644
returnedRows,

proc/path-finding/src/main/java/org/neo4j/gds/paths/maxflow/MaxFlowMutateProc.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package org.neo4j.gds.paths.maxflow;
2121

22+
import org.neo4j.gds.applications.algorithms.machinery.MemoryEstimateResult;
2223
import org.neo4j.gds.procedures.GraphDataScienceProcedures;
2324
import org.neo4j.gds.procedures.algorithms.pathfinding.MaxFlowMutateResult;
2425
import org.neo4j.procedure.Context;
@@ -30,18 +31,30 @@
3031
import java.util.stream.Stream;
3132

3233
import static org.neo4j.gds.paths.maxflow.MaxFlowConstants.MAXFLOW_DESCRIPTION;
34+
import static org.neo4j.gds.procedures.ProcedureConstants.MEMORY_ESTIMATION_DESCRIPTION;
3335
import static org.neo4j.procedure.Mode.READ;
3436

3537
public class MaxFlowMutateProc {
38+
private static final String proc = "gds.maxFlow.mutate";
39+
3640
@Context
3741
public GraphDataScienceProcedures facade;
3842

39-
@Procedure(value = "gds.maxFlow.mutate", mode = READ)
43+
@Procedure(value = proc, mode = READ)
4044
@Description(MAXFLOW_DESCRIPTION)
4145
public Stream<MaxFlowMutateResult> maxFlow(
4246
@Name(value = "graphName") String graphName,
4347
@Name(value = "configuration", defaultValue = "{}") Map<String, Object> configuration
4448
) {
4549
return facade.algorithms().pathFinding().maxFlowMutate(graphName, configuration);
4650
}
51+
52+
@Procedure(value = proc + ".estimate", mode = READ)
53+
@Description(MEMORY_ESTIMATION_DESCRIPTION)
54+
public Stream<MemoryEstimateResult> estimate(
55+
@Name(value = "graphNameOrConfiguration") Object graphNameOrConfiguration,
56+
@Name(value = "algoConfiguration") Map<String, Object> algoConfiguration
57+
) {
58+
return facade.algorithms().pathFinding().maxFlowMutateEstimate(graphNameOrConfiguration, algoConfiguration);
59+
}
4760
}

proc/path-finding/src/main/java/org/neo4j/gds/paths/maxflow/MaxFlowStatsProc.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package org.neo4j.gds.paths.maxflow;
2121

22+
import org.neo4j.gds.applications.algorithms.machinery.MemoryEstimateResult;
2223
import org.neo4j.gds.procedures.GraphDataScienceProcedures;
2324
import org.neo4j.gds.procedures.algorithms.pathfinding.MaxFlowStatsResult;
2425
import org.neo4j.procedure.Context;
@@ -30,18 +31,31 @@
3031
import java.util.stream.Stream;
3132

3233
import static org.neo4j.gds.paths.maxflow.MaxFlowConstants.MAXFLOW_DESCRIPTION;
34+
import static org.neo4j.gds.procedures.ProcedureConstants.MEMORY_ESTIMATION_DESCRIPTION;
3335
import static org.neo4j.procedure.Mode.READ;
3436

3537
public class MaxFlowStatsProc {
38+
private static final String proc = "gds.maxFlow.stats";
39+
3640
@Context
3741
public GraphDataScienceProcedures facade;
3842

39-
@Procedure(name = "gds.maxFlow.stats", mode = READ)
43+
@Procedure(name = proc, mode = READ)
4044
@Description(MAXFLOW_DESCRIPTION)
4145
public Stream<MaxFlowStatsResult> stream(
4246
@Name(value = "graphName") String graphName,
4347
@Name(value = "configuration", defaultValue = "{}") Map<String, Object> configuration
4448
) {
4549
return facade.algorithms().pathFinding().maxFlowStats(graphName, configuration);
4650
}
51+
52+
@Procedure(value = proc + ".estimate", mode = READ)
53+
@Description(MEMORY_ESTIMATION_DESCRIPTION)
54+
public Stream<MemoryEstimateResult> estimate(
55+
@Name(value = "graphNameOrConfiguration") Object graphNameOrConfiguration,
56+
@Name(value = "algoConfiguration") Map<String, Object> algoConfiguration
57+
) {
58+
return facade.algorithms().pathFinding().maxFlowStatsEstimate(graphNameOrConfiguration, algoConfiguration);
59+
}
60+
4761
}

0 commit comments

Comments
 (0)