Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Traversing tree in Neo4J

I am storing a very complex tree in Neo4J. This tree can be very deep. At later point of time, I need to traverse this tree in breadth first format. What would be the most efficient way of achieving this?

  1. Is there is possibility to achieve this through Cypher?
  2. Shall I use Neo4J traversal APIs?
  3. Shall I fetch all child nodes with relationships using Cypher and construct the tree by my own(writing logic in Java).
like image 685
Piyush Avatar asked Jan 25 '26 16:01

Piyush


1 Answers

Use the Traversal Framework, it supports BFSs. Cypher is better suited to declarative graph pattern matching-like operations, while traversals require imperative navigation operations.

like image 60
Gabor Szarnyas Avatar answered Jan 28 '26 16:01

Gabor Szarnyas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!