use of org.neo4j.graphalgo.impl.path.ShortestPath in project graphdb by neo4j-attic.
the class TestShortestPath method makeSureDescentStopsWhenPathIsFound.
@Test
public void makeSureDescentStopsWhenPathIsFound() throws Exception {
/*
* (a)==>(b)==>(c)==>(d)==>(e)
* \
* v
* (f)-->(g)-->(h)-->(i)
*/
graph.makeEdgeChain("a,b,c,d,e");
graph.makeEdgeChain("a,b,c,d,e");
graph.makeEdgeChain("a,f,g,h,i");
Node a = graph.getNode("a");
Node b = graph.getNode("b");
Node c = graph.getNode("c");
final Set<Node> allowedNodes = new HashSet<Node>(Arrays.asList(a, b, c));
PathFinder<Path> finder = new ShortestPath(100, Traversal.expanderForAllTypes(Direction.OUTGOING)) {
@Override
protected Collection<Node> filterNextLevelNodes(Collection<Node> nextNodes) {
for (Node node : nextNodes) {
if (!allowedNodes.contains(node)) {
fail("Node " + node.getProperty(KEY_ID) + " shouldn't be expanded");
}
}
return nextNodes;
}
};
finder.findAllPaths(a, c);
}
Aggregations