Tree Traversal

Hello,

What are the options in traversing a tree (say depth first) with Neo4j? Is bllom capable of doing this or is there any declarative approach to do so?

Thank you.

If you want to write a java program that interacts with Neo4j, there is an entire traversal API for java that does exactly this, and traversing in any way you want, like depth first, is easy:

https://neo4j.com/docs/java-reference/current/tutorial-traversal/

As for cypher -- you can definitely traverse a tree easily using it, but you can't do it depth first per se. Cypher is a declarative language, that means that you specify what you want, and not how to get it. If you say you want depth first traversal, then that is fundamentally not declarative, but rather an imperative way of accessing the graph, and that's what the Java API is there for.

Ultimately both are supported, by Cypher's great strength is that you don't have to know or care which way the traversal goes. You just focus on specifying where you want to traverse to, and it gets you the data you want.

Hi David,

Thank you for your reply. I am using version 1.2.1 and was wondering what add-on etc. I need to install for the Java API and interfacing and providing the code. Is this compiled or is it interpreted? How is the interface? Also, are there any programs such as Bloom that can do this traversal?

It seems that the link you provided above assumes that person already knows the answers to the above questions.

You can also use the Expander procedures in the APOC procedure library:

https://neo4j.com/docs/labs/apoc/current/graph-querying/

The Java API that comes with Neo4j is what you use to access the traversal API. Here are the relevant docs for writing java programs. As such, they're compiled, not interpreted.

Bloom does not support this kind of traversal because it's focused on visualization. The interface of what I'm talking about is straight java code.

I recommend you try this out, go a bit further down the learning path, and then come back and post a follow-up question that's a bit more specific, on what kind of traversal you're trying to do, what you've tried, and so on.