title: Traversing Graph using Cypher and presenting resultset as a table
body: <p>Greeting to All!</p>
  
  <p>I am a beginner with Neo4j and Cypher and have a problem with the following functionality:</p>
  
  <ol>
  <li><p>I have a acyclic directed graph of Nodes that are connected with <code>:DATA_FLOWS</code> edges</p></li>
  <li><p>There could be more than one edge between two Nodes as these edges could have different Edge property - scenario_id</p></li>
  <li><p>When I select one or more nodes (by group) and try to filter by one or more scenario_id (property of the edge) I would like to see all the dependent Nodes of a certain depth (*..n) that depend on my selection and edge filter</p></li>
  <li><p>I am using the following query:
  <code>
  match p= (src:Node)-[:DATA_FLOWS*..5]-&gt;(dst:Node)
  where src.group_id IN {Group} and all(x in RELATIONSHIPS(p) WHERE x.scenario_id IN  {Scenario} ) 
  RETURN p;
  </code></p></li>
  <li><p>This looks OK in Neo4j browser that presents the results in a nice visual way, but I need to run this query in Tom Sawyer Perspective, which expects flat table-like result set, rather than Json...</p></li>
  <li><p>So my query, after too many unsuccessful attempts, looks like:
  <code>
  match p= (src:Node)-[:DATA_FLOWS*..5]-&gt;(dst:Node)
  where src.group_id IN {Group} and all(x in RELATIONSHIPS(p) WHERE x.scenario_id IN  {Scenario} ) 
  WITH p
  MATCH (a)-[r:DATA_FLOWS]-&gt;(b)
  where all(x in RELATIONSHIPS(p) WHERE ID(x) = ID(r)) 
  RETURN a.id, r.scenario_id, b.id
  </code></p></li>
  <li>I don't think it brings correct results and it is extremely slow...</li>
  </ol>
  
  <p>I would greatly appreciate if anyone provides me any suggestions on how to improve, rewrite, etc this query and get a better performance.</p>
  
  <p>Thank you in advance,
  Vlad</p>