I have a setup like the attached image. Orange nodes denotes the cases and the Blue nodes denotes the Performers of various activities within that case.
I would like to query each case in turn. Within each case, I need to add relationship
[:RELATED {value: 1}]
from nodei to nodek , for all k that lies in between(nodes whose ID fall between i and j) those pair of Performer nodes (nodei,nodej) such that :
Name(nodei) == Name( nodej )
and
| ID(nodei) - ID(nodej) | >= 2
[Example and Expected Output]:
In Case1, since Performer nodes with ID:1 and ID:4 satisfy the criteria, so relationships are added between:
Node(ID:1) to Node(ID:2) Node(ID:1) to Node(ID:3)
In Case2, Performer nodes with ID:2 and ID:4 satisfy the criteria, so relationships are added between:
Node(ID:2) to Node(ID:3)
In Case3, there are two sets of nodes satisfying the criteria,
a. For Node(ID:1) and Node(ID:4) add relationships from
Node(ID:1) to Node(ID:2) Node(ID:1) to Node(ID:3)
b. For Node(ID:3) and Node(ID:5), add relationship from
Node(ID:3) to Node(ID:4)
Hint needed in formulating CYPHER queries for the above case.
Thanks in advance.
Node(ID:1) to Node(ID:2)
? Not the same name and (2 - 1) == 1. – wassgren