|
32 | 32 | import org.neo4j.gds.api.Graph; |
33 | 33 | import org.neo4j.gds.compat.Neo4jProxy; |
34 | 34 | import org.neo4j.gds.compat.TestLog; |
| 35 | +import org.neo4j.gds.core.Aggregation; |
35 | 36 | import org.neo4j.gds.core.utils.mem.MemoryRange; |
36 | 37 | import org.neo4j.gds.core.utils.progress.EmptyTaskRegistryFactory; |
37 | 38 | import org.neo4j.gds.core.utils.progress.tasks.ProgressTracker; |
@@ -85,7 +86,7 @@ void shouldComputeMemoryEstimation(int nodeCount, long expectedBytes) { |
85 | 86 | } |
86 | 87 |
|
87 | 88 | // https://en.wikipedia.org/wiki/Yen%27s_algorithm#/media/File:Yen's_K-Shortest_Path_Algorithm,_K=3,_A_to_F.gif |
88 | | - @GdlGraph |
| 89 | + @GdlGraph(aggregation = Aggregation.SINGLE) |
89 | 90 | private static final String DB_CYPHER = |
90 | 91 | "CREATE" + |
91 | 92 | " (c:C {id: 0})" + |
@@ -165,7 +166,8 @@ static Stream<List<String>> pathInput() { |
165 | 166 | @ParameterizedTest |
166 | 167 | @MethodSource("pathInput") |
167 | 168 | void compute(Collection<String> expectedPaths) { |
168 | | - assertResult(graph, idFunction, expectedPaths); |
| 169 | + |
| 170 | + assertResult(graph, idFunction, expectedPaths, false); |
169 | 171 | } |
170 | 172 |
|
171 | 173 | @Test |
@@ -238,8 +240,13 @@ void shouldCloseProgressTasksOnEmptyResult() { |
238 | 240 | ); |
239 | 241 | } |
240 | 242 |
|
241 | | - private static void assertResult(Graph graph, IdFunction idFunction, Collection<String> expectedPaths) { |
242 | | - var expectedPathResults = expectedPathResults(idFunction, expectedPaths); |
| 243 | + private static void assertResult( |
| 244 | + Graph graph, |
| 245 | + IdFunction idFunction, |
| 246 | + Collection<String> expectedPaths, |
| 247 | + boolean trackRelationships |
| 248 | + ) { |
| 249 | + var expectedPathResults = expectedPathResults(idFunction, expectedPaths, trackRelationships); |
243 | 250 |
|
244 | 251 | var firstResult = expectedPathResults |
245 | 252 | .stream() |
@@ -267,7 +274,11 @@ private static void assertResult(Graph graph, IdFunction idFunction, Collection< |
267 | 274 | } |
268 | 275 |
|
269 | 276 | @NotNull |
270 | | - private static Set<PathResult> expectedPathResults(IdFunction idFunction, Collection<String> expectedPaths) { |
| 277 | + private static Set<PathResult> expectedPathResults( |
| 278 | + IdFunction idFunction, |
| 279 | + Collection<String> expectedPaths, |
| 280 | + boolean trackRelationships |
| 281 | + ) { |
271 | 282 | var index = new MutableInt(0); |
272 | 283 | return expectedPaths.stream() |
273 | 284 | .map(expectedPath -> new GDLHandler.Builder() |
@@ -312,7 +323,7 @@ private static Set<PathResult> expectedPathResults(IdFunction idFunction, Collec |
312 | 323 | .sourceNode(sourceNode.getId()) |
313 | 324 | .targetNode(targetNode.getId()) |
314 | 325 | .nodeIds(nodeIds) |
315 | | - .relationshipIds(relationshipIds) |
| 326 | + .relationshipIds(trackRelationships ? relationshipIds : new long[0]) |
316 | 327 | .costs(costs) |
317 | 328 | .build(); |
318 | 329 | }) |
@@ -375,7 +386,7 @@ Stream<List<String>> pathInput() { |
375 | 386 | @ParameterizedTest |
376 | 387 | @MethodSource("pathInput") |
377 | 388 | void compute(Collection<String> expectedPaths) { |
378 | | - assertResult(graph, idFunction, expectedPaths); |
| 389 | + assertResult(graph, idFunction, expectedPaths, true); |
379 | 390 | } |
380 | 391 | } |
381 | 392 | } |
0 commit comments