use of org.neo4j.graphdb.traversal.Traverser in project neo4j by neo4j.
the class TreeGraphTest method pathsIteratorReturnAllNodes.
@Test
public void pathsIteratorReturnAllNodes() throws Exception {
try (Transaction transaction = beginTx()) {
Traverser traverser = getGraphDb().traversalDescription().traverse(node("1"));
int count = 0;
for (Path path : traverser) {
assertNotNull("returned paths should not be null. path #" + count, path);
count++;
}
assertEquals(13, count);
}
}
use of org.neo4j.graphdb.traversal.Traverser in project neo4j by neo4j.
the class DepthPitfallGraphTest method testAllUniqueRelationshipPathsAreReturned.
private void testAllUniqueRelationshipPathsAreReturned(TraversalDescription description) throws Exception {
Set<String> expected = new HashSet<String>(Arrays.asList(NODE_UNIQUE_PATHS));
expected.addAll(Arrays.asList(RELATIONSHIP_UNIQUE_EXTRA_PATHS));
Traverser traverser = description.uniqueness(Uniqueness.RELATIONSHIP_PATH).traverse(node("1"));
expectPaths(traverser, expected);
}
use of org.neo4j.graphdb.traversal.Traverser in project neo4j by neo4j.
the class DepthPitfallGraphTest method testSmallestPossibleInit.
@Test
public void testSmallestPossibleInit() throws Exception {
Traverser traversal = getGraphDb().traversalDescription().traverse(node("1"));
int count = 0;
try (Transaction transaction = beginTx()) {
for (Path position : traversal) {
count++;
assertNotNull(position);
assertNotNull(position.endNode());
if (position.length() > 0) {
assertNotNull(position.lastRelationship());
}
assertNotNull(position.length());
}
assertFalse("empty traversal", count == 0);
}
}
use of org.neo4j.graphdb.traversal.Traverser in project neo4j by neo4j.
the class DepthPitfallGraphTest method testAllNodesAreReturnedOnce.
private void testAllNodesAreReturnedOnce(TraversalDescription traversal) {
Traverser traverser = traversal.uniqueness(Uniqueness.NODE_GLOBAL).traverse(node("1"));
expectNodes(traverser, "1", "2", "3", "4", "5", "6");
}
use of org.neo4j.graphdb.traversal.Traverser in project neo4j by neo4j.
the class DepthPitfallGraphTest method testRelationshipsAreReturnedOnceWhenSufficientRecentlyUnique.
private void testRelationshipsAreReturnedOnceWhenSufficientRecentlyUnique(TraversalDescription description) throws Exception {
Traverser traverser = description.uniqueness(Uniqueness.RELATIONSHIP_RECENT, THE_WORLD_AS_WE_KNOW_IT.length).traverse(node("1"));
expectRelationships(traverser, THE_WORLD_AS_WE_KNOW_IT);
}
Aggregations