Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-24-2021 01:43 AM
I have a tree representing a nested (Java)-switch-statement, so there are these nodes:
(:Switch {var_ref: <some_id>})
(:Case {test: <value>})
(:Value {value: <value>)
a switch may have many case-children. A case may have either a switch or a value child.
I also have a :param that holds a map {id -> value}
How can I find the "active" value with a specific param?
for exampe with this tree:
switch ref1
case 1:
switch ref2
case 1: 4711
case 2: 42
case 3:
switch ref3:
case 1: 123
case 2: 456
case 2: 99
with params
{ref1: 1, ref2: 1, ref3: 1} -> 4711
{ref1: 2, ref2: 1, ref3: 1} -> 99
{ref1: 1, ref2: 3, ref3: 1} -> 123
I've seen apoc.path.expand
but it can't restrict a path by properties.
So one idea would be to (using Java) get all switch
, get the value of the references variable, get all case
-children and set an :Active
label it the case's test matches the value of the ref..
Or I could get all paths to vaues paths = (:Root)-[*]-(:Value)
and the I think it may be possible to filter these paths.
EDIT:
I was playing with this a little more, and its (obviously) very easy when I just change the relationship for the "inactive" cases. So all nodes are connected by :HAS
and using the API I change (switch)-[:HAS]->(case)
to (switch)-[:HAS_INACTIVE]->(case)
for all case
-nodes that do not eval to true
. With that I just have:
MATCH (:Choose)-[:HAS*]->(v:Value) return v
I still wonder if there is a way without using the API.
All the sessions of the conference are now available online