Skip to content

Commit c90296f

Browse files
Tests for not-multigraphs do not track relationships
Co-authored-by: Veselin Nikolov <veselin.nikolov@neotechnology.com>
1 parent ad92943 commit c90296f

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

algo/src/test/java/org/neo4j/gds/paths/yens/YensTest.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.neo4j.gds.api.Graph;
3333
import org.neo4j.gds.compat.Neo4jProxy;
3434
import org.neo4j.gds.compat.TestLog;
35+
import org.neo4j.gds.core.Aggregation;
3536
import org.neo4j.gds.core.utils.mem.MemoryRange;
3637
import org.neo4j.gds.core.utils.progress.EmptyTaskRegistryFactory;
3738
import org.neo4j.gds.core.utils.progress.tasks.ProgressTracker;
@@ -85,7 +86,7 @@ void shouldComputeMemoryEstimation(int nodeCount, long expectedBytes) {
8586
}
8687

8788
// 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)
8990
private static final String DB_CYPHER =
9091
"CREATE" +
9192
" (c:C {id: 0})" +
@@ -165,7 +166,8 @@ static Stream<List<String>> pathInput() {
165166
@ParameterizedTest
166167
@MethodSource("pathInput")
167168
void compute(Collection<String> expectedPaths) {
168-
assertResult(graph, idFunction, expectedPaths);
169+
170+
assertResult(graph, idFunction, expectedPaths, false);
169171
}
170172

171173
@Test
@@ -238,8 +240,13 @@ void shouldCloseProgressTasksOnEmptyResult() {
238240
);
239241
}
240242

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);
243250

244251
var firstResult = expectedPathResults
245252
.stream()
@@ -267,7 +274,11 @@ private static void assertResult(Graph graph, IdFunction idFunction, Collection<
267274
}
268275

269276
@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+
) {
271282
var index = new MutableInt(0);
272283
return expectedPaths.stream()
273284
.map(expectedPath -> new GDLHandler.Builder()
@@ -312,7 +323,7 @@ private static Set<PathResult> expectedPathResults(IdFunction idFunction, Collec
312323
.sourceNode(sourceNode.getId())
313324
.targetNode(targetNode.getId())
314325
.nodeIds(nodeIds)
315-
.relationshipIds(relationshipIds)
326+
.relationshipIds(trackRelationships ? relationshipIds : new long[0])
316327
.costs(costs)
317328
.build();
318329
})
@@ -375,7 +386,7 @@ Stream<List<String>> pathInput() {
375386
@ParameterizedTest
376387
@MethodSource("pathInput")
377388
void compute(Collection<String> expectedPaths) {
378-
assertResult(graph, idFunction, expectedPaths);
389+
assertResult(graph, idFunction, expectedPaths, true);
379390
}
380391
}
381392
}

0 commit comments

Comments
 (0)