use of org.neo4j.graphdb.RelationshipExpander in project graphdb by neo4j-attic.
the class TestOrderByTypeExpander method makeSureNodesAreTraversedInCorrectOrder.
@Test
public void makeSureNodesAreTraversedInCorrectOrder() {
RelationshipType next = DynamicRelationshipType.withName("NEXT");
RelationshipType firstComment = DynamicRelationshipType.withName("FIRST_COMMENT");
RelationshipType comment = DynamicRelationshipType.withName("COMMENT");
RelationshipExpander expander = new OrderedByTypeExpander().add(firstComment).add(comment).add(next);
Iterator<Node> itr = Traversal.description().depthFirst().expand(expander).traverse(referenceNode()).nodes().iterator();
assertOrder(itr, "A1", "C1", "C2", "C3", "A2", "C4", "C5", "C6", "A3", "C7", "C8", "C9");
expander = new OrderedByTypeExpander().add(next).add(firstComment).add(comment);
itr = Traversal.description().depthFirst().expand(expander).traverse(referenceNode()).nodes().iterator();
assertOrder(itr, "A1", "A2", "A3", "C7", "C8", "C9", "C4", "C5", "C6", "C1", "C2", "C3");
}
use of org.neo4j.graphdb.RelationshipExpander in project graphdb by neo4j-attic.
the class TestShortestPath method testExactDepthFinder.
@Test
public void testExactDepthFinder() {
// Layout (a to k):
//
// (a)--(c)--(g)--(k)
// / /
// (b)-----(d)------(j)
// | \ /
// (e)--(f)--(h)--(i)
//
graph.makeEdgeChain("a,c,g,k");
graph.makeEdgeChain("a,b,d,j,k");
graph.makeEdgeChain("b,e,f,h,i,j");
graph.makeEdgeChain("d,h");
RelationshipExpander expander = Traversal.expanderForTypes(MyRelTypes.R1, Direction.OUTGOING);
Node a = graph.getNode("a");
Node k = graph.getNode("k");
assertPaths(GraphAlgoFactory.pathsWithLength(expander, 3).findAllPaths(a, k), "a,c,g,k");
assertPaths(GraphAlgoFactory.pathsWithLength(expander, 4).findAllPaths(a, k), "a,b,d,j,k");
assertPaths(GraphAlgoFactory.pathsWithLength(expander, 5).findAllPaths(a, k));
assertPaths(GraphAlgoFactory.pathsWithLength(expander, 6).findAllPaths(a, k), "a,b,d,h,i,j,k");
assertPaths(GraphAlgoFactory.pathsWithLength(expander, 7).findAllPaths(a, k), "a,b,e,f,h,i,j,k");
assertPaths(GraphAlgoFactory.pathsWithLength(expander, 8).findAllPaths(a, k));
}
Aggregations