use of org.neo4j.graphdb.traversal.TraversalDescription in project neo4j by neo4j.
the class SpecificDepthTraversalTest method shouldGetSecondNodeWhenAtIsTwoBreadthFirst.
@Test
public void shouldGetSecondNodeWhenAtIsTwoBreadthFirst() {
TraversalDescription description = getGraphDb().traversalDescription().breadthFirst().evaluator(Evaluators.atDepth(2));
expectNodes(description.traverse(getNodeWithName("6")), "4");
}
use of org.neo4j.graphdb.traversal.TraversalDescription in project neo4j by neo4j.
the class SpecificDepthTraversalTest method shouldGetStartNodeWhenAtIsZeroBreadthFirst.
@Test
public void shouldGetStartNodeWhenAtIsZeroBreadthFirst() {
TraversalDescription description = getGraphDb().traversalDescription().breadthFirst().evaluator(Evaluators.atDepth(0));
expectNodes(description.traverse(getNodeWithName("2")), "2");
}
use of org.neo4j.graphdb.traversal.TraversalDescription in project neo4j by neo4j.
the class SpecificDepthTraversalTest method shouldGetStartNodeOnDepthZero.
@Test
public void shouldGetStartNodeOnDepthZero() {
TraversalDescription description = getGraphDb().traversalDescription().evaluator(Evaluators.atDepth(0));
expectNodes(description.traverse(getNodeWithName("6")), "6");
}
use of org.neo4j.graphdb.traversal.TraversalDescription in project neo4j by neo4j.
the class SpecificDepthTraversalTest method shouldGetCorrectNodesAtDepthZero.
@Test
public void shouldGetCorrectNodesAtDepthZero() {
TraversalDescription description = getGraphDb().traversalDescription().evaluator(Evaluators.fromDepth(0)).evaluator(Evaluators.toDepth(0));
expectNodes(description.traverse(getNodeWithName("6")), "6");
}
use of org.neo4j.graphdb.traversal.TraversalDescription in project neo4j by neo4j.
the class TestTraversalWithIterable method useTraverserInsideTraverser.
@Test
public void useTraverserInsideTraverser() throws Exception {
/*
* (a)-->(b)-->(c)
* |
* \/
* (d)-->(e)-->(f)
*
*/
createGraph("a FIRST d", "a TO b", "b TO c", "d TO e", "e TO f");
try (Transaction tx = beginTx()) {
TraversalDescription firstTraverser = getGraphDb().traversalDescription().relationships(RelationshipType.withName("FIRST")).evaluator(Evaluators.toDepth(1));
final Iterable<Path> firstResult = firstTraverser.traverse(getNodeWithName("a"));
Iterable<Node> startNodesForNestedTraversal = new IterableWrapper<Node, Path>(firstResult) {
@Override
protected Node underlyingObjectToObject(Path path) {
return path.endNode();
}
};
TraversalDescription nestedTraversal = getGraphDb().traversalDescription().evaluator(Evaluators.atDepth(2));
expectPaths(nestedTraversal.traverse(startNodesForNestedTraversal), "a,b,c", "d,e,f");
tx.success();
}
}
Aggregations