@Test public void shouldBeAbleToGetShortestPaths() throws Exception { long[] nodes = createMoreComplexGraph(); // /paths List<Object> result = serialize( actions.findPaths( nodes[0], nodes[1], MapUtil.map( "max_depth", 2, "algorithm", "shortestPath", "relationships", MapUtil.map("type", "to", "direction", "out")))); assertPaths(2, nodes, 2, result); // /path Map<String, Object> path = serialize( actions.findSinglePath( nodes[0], nodes[1], MapUtil.map( "max_depth", 2, "algorithm", "shortestPath", "relationships", MapUtil.map("type", "to", "direction", "out")))); assertPaths(1, nodes, 2, Arrays.<Object>asList(path)); // /path {single: false} (has no effect) path = serialize( actions.findSinglePath( nodes[0], nodes[1], MapUtil.map( "max_depth", 2, "algorithm", "shortestPath", "relationships", MapUtil.map("type", "to", "direction", "out"), "single", false))); assertPaths(1, nodes, 2, Arrays.<Object>asList(path)); }
@Test public void shouldBeAbleToGetPathsUsingDijkstra() throws Exception { long[] nodes = createDijkstraGraph(true); // /paths List<Object> result = serialize( actions.findPaths( nodes[0], nodes[1], map( "algorithm", "dijkstra", "cost_property", "cost", "relationships", map("type", "to", "direction", "out")))); assertPaths(1, nodes, 6, result); // /path Map<String, Object> path = serialize( actions.findSinglePath( nodes[0], nodes[1], map( "algorithm", "dijkstra", "cost_property", "cost", "relationships", map("type", "to", "direction", "out")))); assertPaths(1, nodes, 6, Arrays.<Object>asList(path)); assertEquals(6.0d, path.get("weight")); }
@Test(expected = NotFoundException.class) public void shouldHandleNoFoundPathsCorrectly() { long[] nodes = createMoreComplexGraph(); serialize( actions.findSinglePath( nodes[0], nodes[1], map( "max_depth", 2, "algorithm", "shortestPath", "relationships", map("type", "to", "direction", "in"), "single", false))); }