title: Bidirectional recursion in neo4j
body: <p>Cannot find answer online for this.  I want to do a recursive query upstream and downstream on protein interaction map.  If user enters a protein (protein 'C') and depth N=2, I want to return 2 upstream and 2 downstream proteins in the interaction map and the regulation.  However if its upstream then protein 'b' on right side of MATCH needs to come first in the return table and if its downstream direction then protein 'a' on left side of match needs to come first in return table.  How can I do this?</p>
  <p>For instance this is the bidirection but half of the rows are the wrong order in columns 1 and 3.</p>
  <pre><code>MATCH p = (a:Protein { name:'C' })&lt;-[:REGULATES*1..2]-&gt;(b:Protein) 
  WITH *, relationships(p) as r
  RETURN nodes(p)[length(p)-1].name AS Protein1, r[length(p)-1] as Regulates, b.name AS Protein2
  </code></pre>
  <p>I can only get what I want with two calls and switching order or RETURN columns.</p>
  <pre><code>MATCH p = (a:Protein { name:'C' })-[:REGULATES*1..2]-&gt;(b:Protein) 
  WITH *, relationships(p) as r
  RETURN nodes(p)[length(p)-1].name AS Protein1, r[length(p)-1] as Regulates, length(p), b.name AS Protein2
  
  MATCH p = (a:Protein { name:'C' })&lt;-[:REGULATES*1..2]-(b:Protein) 
  WITH *, relationships(p) as r
  RETURN b.name AS Protein1, r[length(p)-1] as Regulates, nodes(p)[length(p)-1].name AS Protein2
  </code></pre>