Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions algo/src/main/java/org/neo4j/graphalgo/ShortestPathProc.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class ShortestPathProc {
public Stream<ShortestPathDijkstra.Result> dijkstraStream(
@Name("startNode") Node startNode,
@Name("endNode") Node endNode,
@Name("propertyName") String propertyName,
@Name(value = "propertyName", defaultValue = "null") String propertyName,
@Name(value = "config", defaultValue = "{}")
Map<String, Object> config) {

Expand Down Expand Up @@ -121,7 +121,7 @@ public Stream<ShortestPathDijkstra.Result> dijkstraStream(
public Stream<DijkstraResult> dijkstra(
@Name("startNode") Node startNode,
@Name("endNode") Node endNode,
@Name("propertyName") String propertyName,
@Name(value = "propertyName", defaultValue="null") String propertyName,
@Name(value = "config", defaultValue = "{}")
Map<String, Object> config) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,54 @@ public static Collection<Object[]> data() {
@Parameterized.Parameter
public String graphImpl;

@Test
public void noWeightStream() throws Exception {
PathConsumer consumer = mock(PathConsumer.class);
DB.execute(
"MATCH (start:Node{type:'start'}), (end:Node{type:'end'}) " +
"CALL algo.shortestPath.stream(start, end) " +
"YIELD nodeId, cost RETURN nodeId, cost")
.accept((Result.ResultVisitor<Exception>) row -> {
consumer.accept((Long) row.getNumber("nodeId"), (Double) row.getNumber("cost"));
return true;
});
verify(consumer, times(2)).accept(anyLong(), anyDouble());
verify(consumer, times(1)).accept(anyLong(), eq(0.0));
verify(consumer, times(1)).accept(anyLong(), eq(1.0));
}

@Test
public void noWeightWrite() throws Exception {
DB.execute(
"MATCH (start:Node{type:'start'}), (end:Node{type:'end'}) " +
"CALL algo.shortestPath(start, end) " +
"YIELD loadMillis, evalMillis, writeMillis, nodeCount, totalCost\n" +
"RETURN loadMillis, evalMillis, writeMillis, nodeCount, totalCost")
.accept((Result.ResultVisitor<Exception>) row -> {
assertEquals(1.0, (Double) row.getNumber("totalCost"), 0.01);
assertEquals(2L, row.getNumber("nodeCount"));
assertNotEquals(-1L, row.getNumber("loadMillis"));
assertNotEquals(-1L, row.getNumber("evalMillis"));
assertNotEquals(-1L, row.getNumber("writeMillis"));
return false;
});

final StepConsumer mock = mock(StepConsumer.class);

DB.execute("MATCH (n) WHERE exists(n.sssp) RETURN id(n) as id, n.sssp as sssp")
.accept(row -> {
mock.accept(
row.getNumber("id").longValue(),
row.getNumber("sssp").intValue());
return true;
});

verify(mock, times(2)).accept(anyLong(), anyInt());

verify(mock, times(1)).accept(anyLong(), eq(0));
verify(mock, times(1)).accept(anyLong(), eq(1));
}

@Test
public void testDijkstraStream() throws Exception {
PathConsumer consumer = mock(PathConsumer.class);
Expand Down