title: Query case-specific nodes in neo4j
body: <p>I have a setup like the attached image. <strong>Orange nodes</strong> denotes the <strong>cases</strong> and the <strong>Blue nodes</strong> denotes the <strong>Performers</strong> of various activities within that case.</p>
  <p><img src="https://i.stack.imgur.com/H0M5H.png" alt="Case specifics nodes" /></p>
  <p>I would like to query each case in turn. Within each case, I need to add relationship</p>
  <pre><code>[:RELATED {value: 1}] 
  </code></pre>
  <p>from <strong>node<sub>i</sub></strong> to <strong>node<sub>k</sub></strong> , for all k that lies in between(nodes whose ID fall between i and j) those pair of Performer nodes (<strong>node<sub>i</sub></strong>,<strong>node<sub>j</sub></strong>) such that :<br/><br/><strong>Name(node<sub>i</sub>)</strong> == <strong>Name( node<sub>j</sub> )</strong> <br/><br/>and <br/><br/>  <strong>| ID(node<sub>i</sub>) - ID(node<sub>j</sub>) | &gt;= 2</strong><br/><br/></p>
  <br/>
  <br/>
  <p><strong>[Example and Expected Output]:</strong></p>
  <ol>
  <li><p>In Case1, since Performer nodes with ID:1 and ID:4 satisfy the criteria, so relationships are added between:</p>
  <pre><code>       Node(ID:1) to Node(ID:2)
  
         Node(ID:1) to Node(ID:3)
  </code></pre>
  </li>
  </ol>
  <br/>
  <ol start="2">
  <li><p>In Case2, Performer nodes with ID:2 and ID:4 satisfy the criteria, so relationships are added between:</p>
  <pre><code>       Node(ID:2) to Node(ID:3)
  </code></pre>
  </li>
  </ol>
  <br/>
  <ol start="3">
  <li><p>In Case3, there are two sets of nodes satisfying the criteria,</p>
  <p>a. For Node(ID:1) and Node(ID:4) add relationships from</p>
  <pre><code>       Node(ID:1) to Node(ID:2)
  
         Node(ID:1) to Node(ID:3)
  </code></pre>
  <p>b. For Node(ID:3) and Node(ID:5), add relationship from</p>
  <pre><code>       Node(ID:3) to Node(ID:4)
  </code></pre>
  </li>
  </ol>
  <p>Hint needed in formulating CYPHER queries for the above case.</p>
  <p>Thanks in advance.</p>