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.

Complex subtree selection

valeriy
Node

Hello. There is a graph.

create
(a:Node {title:"A", ordered:false, active: true}),
(aa:Node {title:"AA", ordered: true, active: true}),
(ab:Node {title:"AB", ordered: false, active: true}),
(ac:Node {title:"AC", ordered: false, active: false}),
(aaa:Node {title:"AAA", ordered: false, active: true}),
(aab:Node {title:"AAB", ordered: false, active: true}),
(aac:Node {title:"AAC", ordered: false, active: true}),
(a)-[:RELATED_WITH { order: 1 }]->(aa),
(a)-[:RELATED_WITH { order: 2 }]->(ab),
(a)-[:RELATED_WITH { order: 3 }]->(ac),
(aa)-[:RELATED_WITH{ order: 1 }]->(aaa),
(aa)-[:RELATED_WITH{ order: 2 }]->(aab),
(aa)-[:RELATED_WITH{ order: 3 }]->(aac)
return *;

For a given start node (for example "A"), I need to find all subnodes, but I can only go down to active nodes (active = true). Also, if a node has the "ordered = true" property set, then I only need to descend to the first active node.

For example, for the graph above, a subtree is expected to be found:

A --> AA -> AAA
|__-> AB

Please help me to make a select (match) query.

0 REPLIES 0
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online