views:

93

answers:

1

I'd like to traverse my graph using the neo4j traversal API, but I need to be able to specify which relationship type to use at every step, and the relationship type to use needs to be a function of the current node. Is there a way to do this?

A: 

Hi there, in the current Traverser API you can't choose the exact relationship to traverse. Instead, you take the more granular approach of node.getRelationships(), chose the one you want and the end onde on it, and so on. The algo gets a bit more verbose than using Traverser, but gives you more flexibility. For a tinkering approach, Gremlin supports the notion of functions for choosing edges to traverse, see here. This will soon be implemented using Blueprint Pipes for Java-level performance.

HTH

/peter neubauer

Hi thank you for your response. I could take the granular approach but I read that the node.getRelationships() method of traversal is supposed to be orders of magnitude slower than using the built in traversals.
James
@James: Using the granular approach shouldn't be slower than the built in traversals unless you mess up somehow. I'd really like to know where you read that? BTW, a new traverser framework is in the works, which can do the kind of traversal that you describe.
nawroth