My problem is very close to this topic: Cypher query: Finding all paths between two nodes filtered by relationship properties but what I'm trying to do is to find path which has increasing value of relationship property along the path. So in that previos topics example solution paths (from A to D) would be:
A->D and A->B->D
I used solution from previous topic
START a=node(1), d=node(4)
MATCH p=a-[r:ACTIVATES*..]->d
WITH head(relationships(p)) as r1,p
WHERE all(r2 in relationships(p)
where r2.temperature > r1.temperature)
return p;
and it works for this example. Problem is when there is path with more then 2 relationships, for example:
activates:50 activates:70 activates:60
(A)-------------->(B)-------------->(C)-------------->(D)
this path unfortunately matches too.
Is there way how to write this query in cypher or I'll have to use gremlin instead?
Thanks for any suggestion.
Update: What I need is some construction like (in pseudo programing language):
WITH head(relationships(p)) as r1,p
FOREACH(r2 in tail(relationships(p)):
r1.temperature < r2.temperature, r1 = r2)
but in cypher if it's posible.