1
votes

enter image description here

Hi,

In the above graph, we have a scenario where in any one of value property of a node is updating, the effect of that value, to be propagated to the remaining nodes. How should this value change event be propagated thru' the cypher query.

Appreciate your support

1
Are there any restrictions on which relationships to follow when matching on downstream nodes? - InverseFalcon
the updates must happen upstream i.e. if the property changes on a node (let's say R5 in the example), all the upstream nodes which has impact shall have the value property re-computed..(e.g. R5 shall have impact on R4, R3, R2 on some scenarios or R5 shall have impact on the S1..S5 nodes) in some scenarios - j2eeuser
Sounds like the rules vary. Without labels or knowing any of the logic of what these nodes are and what meaning is in their relationships, it's rather hard to offer any solutions. I think we'll need something more concrete for how these scenarios are supposed to work, and what criteria to use for what nodes or relationships to traverse, before we can offer any kind of advice. - InverseFalcon
The property (let's say state) need to be re-computed to all the connected nodes upstream. whenever a property is changed in a downstream node, need to traverse all the way (i.e. all the upstream nodes) and trigger the property re-calculate function. I would like to know what is the best way to trigger the propagate the property change events to the upstream nodes. ? Let's say we have relationship defined with labels, so identification of the upstream node isn't an issue - j2eeuser

1 Answers

0
votes

Is the requirement that this particular property should always be the same for this group of nodes? If it must be the same, then I would recommend extracting it into a node instead, and create relationships to that node from all nodes that should be using it.

With the value in a single place, it will only require a single property change on that node and everything will be in the right state.

EDIT

Requirements are rather fuzzy, so my answer will be fuzzy as well.

If you're matching based upon relationship types, then you'll want some kind of multiplicity on the relationship and maybe specifying allowed types in the match. Such as:

MATCH (start:RNode)-[:R45|R34|R23|R12*]->(r:RNode)
WHERE start.ID = 123 (or however you're matching on your start node)

That will match on every single node from your startNode up the relationship chain until there are no more of the allowed relationships to continue traversing.

If you need a more complicated expansion, you may want to look at the APOC Procedure library's Path Expander.

After you find the right matching query, then it should just be a matter of doing the recalculation for all matched nodes.