use of org.neo4j.graphdb.traversal.TraversalDescription in project graphdb by neo4j-attic.
the class SmallestGraphEverTest method testTraverseRelationshipsWithStartNodeNotIncluded.
@Test
@SuppressWarnings("deprecation")
public void testTraverseRelationshipsWithStartNodeNotIncluded() throws Exception {
TraversalDescription traversal = Traversal.description().filter(Traversal.returnAllButStartNode());
int count = 0;
for (Relationship rel : traversal.traverse(referenceNode()).relationships()) {
count++;
}
assertEquals(1, count);
}
use of org.neo4j.graphdb.traversal.TraversalDescription in project graphdb by neo4j-attic.
the class TestMultipleFilters method testNarrowingFilters.
@Test
public void testNarrowingFilters() {
Evaluator mustBeConnectedToK = new MustBeConnectedToNodeFilter(getNodeWithName("k"));
Evaluator mustNotHaveMoreThanTwoOutRels = new Evaluator() {
public Evaluation evaluate(Path path) {
return Evaluation.ofIncludes(IteratorUtil.count(path.endNode().getRelationships(Direction.OUTGOING)) <= 2);
}
};
TraversalDescription description = Traversal.description().evaluator(mustBeConnectedToK);
expectNodes(description.traverse(referenceNode()), "b", "c");
expectNodes(description.evaluator(mustNotHaveMoreThanTwoOutRels).traverse(referenceNode()), "c");
}
use of org.neo4j.graphdb.traversal.TraversalDescription in project neo4j by neo4j.
the class TestMultiPruneEvaluators method testMaxDepthAndCustomPruneEvaluatorCombined.
@Test
public void testMaxDepthAndCustomPruneEvaluatorCombined() {
Evaluator lessThanThreeRels = new Evaluator() {
public Evaluation evaluate(Path path) {
return count(path.endNode().getRelationships(Direction.OUTGOING).iterator()) < 3 ? Evaluation.INCLUDE_AND_PRUNE : Evaluation.INCLUDE_AND_CONTINUE;
}
};
TraversalDescription description = getGraphDb().traversalDescription().evaluator(Evaluators.all()).evaluator(toDepth(1)).evaluator(lessThanThreeRels);
Set<String> expectedNodes = new HashSet<String>(asList("a", "b", "c", "d", "e"));
try (Transaction tx = beginTx()) {
for (Path position : description.traverse(node("a"))) {
String name = (String) position.endNode().getProperty("name");
assertTrue(name + " shouldn't have been returned", expectedNodes.remove(name));
}
tx.success();
}
assertTrue(expectedNodes.isEmpty());
}
use of org.neo4j.graphdb.traversal.TraversalDescription in project neo4j by neo4j.
the class SmallestGraphEverTest method testTraverseRelationshipsWithStartNodeNotIncluded.
@Test
public void testTraverseRelationshipsWithStartNodeNotIncluded() throws Exception {
try (Transaction transaction = beginTx()) {
TraversalDescription traversal = getGraphDb().traversalDescription().evaluator(excludeStartPosition());
assertEquals(1, Iterables.count(traversal.traverse(node("1")).relationships()));
}
}
use of org.neo4j.graphdb.traversal.TraversalDescription in project neo4j by neo4j.
the class SpecificDepthTraversalTest method shouldGetCorrectNodeAtDepthOne.
@Test
public void shouldGetCorrectNodeAtDepthOne() {
TraversalDescription description = getGraphDb().traversalDescription().evaluator(Evaluators.atDepth(1));
expectNodes(description.traverse(getNodeWithName("6")), "5");
}
Aggregations