title: neo4j single pass over graph but multiple matches
body: <p>I have a graph in neo4j with vertices of:</p>
  
  <pre><code>person:ID,name,value:int,:LABEL
  1,Alice,1,Person
  2,Bob,0,Person
  3,Charlie,0,Person
  4,David,0,Person
  5,Esther,0,Person
  6,Fanny,0,Person
  7,Gabby,0,Person
  8,XXXX,1,Person
  </code></pre>
  
  <p>and edges:</p>
  
  <pre><code>:START_ID,:END_ID,:TYPE
  1,2,call
  2,3,text
  3,2,text
  6,3,text
  5,6,text
  5,4,call
  4,1,call
  4,5,text
  1,5,call
  1,8,call
  6,8,call
  6,8,text
  8,6,text
  7,1,text
  </code></pre>
  
  <p>imported into neo4j like:</p>
  
  <pre><code>DATA_DIR_SAMPLE=/data_network/
  $NEO4J_HOME/bin/neo4j-admin import --mode=csv \
    --database=graph.db \
    --nodes:Person ${DATA_DIR_SAMPLE}/vertices.csv \
    --relationships ${DATA_DIR_SAMPLE}/edges.csv
  </code></pre>
  
  <p>which looks like:
  <a href="https://i.stack.imgur.com/3bxUl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3bxUl.png" alt="enter image description here"></a></p>
  
  <p>Now when querying the graph like:</p>
  
  <pre><code>MATCH (source:Person)-[*1]-(destination:Person)
  RETURN source.name, source.value, avg(destination.value), 'undir_1_any' as type
  UNION ALL
  MATCH (source:Person)-[*2]-(destination:Person)
  RETURN source.name, source.value, avg(destination.value), 'undir_2_any' as type
  </code></pre>
  
  <p>one can see that the graph is traversed multiple times, and additionally as I want to obtain a table like:</p>
  
  <pre><code>Vertex | value | type_undir_1_any | type_undir_2_any
  Alice  | 1     | 0.2              |  0
  </code></pre>
  
  <p>an additional aggregation step (pivot/reshape) would be required</p>
  
  <p><a href="https://i.stack.imgur.com/cqefR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cqefR.png" alt="enter image description here"></a></p>
  
  <p>In the future, I would like to add the following patterns</p>
  
  <ul>
  <li>undirected  | directed</li>
  <li>all relations | type of relation</li>
  <li>as outlined up to 3 levels into the graph
  and all permutations of these</li>
  </ul>
  
  <p><strong>Is there a better way to combine the queries?</strong></p>