Hi Peter, [I'm sure the Greliministas will provide an answer too, but here's the native Neo4j APIs' take]
In the Neo4j simple traverser framework, you can set max depth to end of graph. But you constrain the types of relationships you allow the traverser to traverse. That way your traversals tend to end at nodes where there are no more relationships (that you've declared the traverser can traverse) to follow. Edited from the Doctor Who Koans (https://github.com/jimwebber/neo4j-tutorial), E.g. Traverser t = theDoctor.traverse(Order.DEPTH_FIRST, StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL_BUT_START_NODE, DoctorWhoUniverseGenerator.COMPANION_OF, Direction.INCOMING); The new Neo4j traverser framework takes a different approach. It allows the writer to embed some logic which determines at each hop of a traversal whether the current node is to be included in the results, and whether or not to continue searching down the current subgraph, e.g. Traverser traverser = Traversal.description() .relationships(DoctorWhoUniverseGenerator.PLAYED, Direction.INCOMING) .breadthFirst() .evaluator(new Evaluator() { public Evaluation evaluate(Path path) { if (path.endNode().hasRelationship(DoctorWhoUniverseGenerator.REGENERATED_TO, Direction.BOTH)) { return Evaluation.INCLUDE_AND_CONTINUE; } else { return Evaluation.EXCLUDE_AND_PRUNE; } } }).traverse(theDoctor); You can see how you could adapt this to address your domain: public Evaluation evaluate(Path path) { if (path.endNode().hasRelationship(RELATES_TO, Direction.BOTH)) { return Evaluation.EXCLUDE_AND_CONTINUE; } else if (path.endNode().hasRelationship(RELATES_TO, Direction.INCOMING)) { return Evaluation.EXCLUDE_AND_CONTINUE; } else { return Evaluation.INCLUDE_AND_PRUNE; } } Hope that helps a bit, and thanks for the tweet about the forums (Anders registered a redirect). Jim _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

