cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

AND/OR trees queries in Neo4j

I'm representing AND/OR trees in Neo4j as in the figure below (with AND and OR nodes and corresponding relationships). The tree's leaves are properties representing boolean values (green = true, red = false).

Now, I'm looking for an algorithm (or cypher query) to traverse each tree to know whether there is at least a valid path (a set of leaves that satisfies the AND/OR conditions) from the leaves or not to the tree's root. For example, in the figure there is such a path, thus the algorithm should return true (and perhaps also the nodes part of the path).

1 REPLY 1

This problem is ideal for a custom procedure. If you want to go in this direction, I would be glad to help get you started or even develop something. I have developed procedures for my application that iterate over a tree to calculate metrics. This is the same, just a different metric.

Maybe one of the APOC experts has an alternative solution, so you don’t need to develop something.