title: Return all nodes and relations among nodes in path
body: <p>First time asking on SO and a newby of cypher and neo4j.</p>
  
  <p>I need to get all the nodes, and all their relationships, that compose the lineage of a particular node; to display them in a directed graph I need a list of <code>nodes</code> and a list of the relationships (<code>links</code>).
  This is my dummy <a href="https://i.stack.imgur.com/vFkC1.png" rel="nofollow noreferrer">set of nodes</a>, and this is what I want to get (nodes plus links): <a href="https://i.stack.imgur.com/YUTzx.png" rel="nofollow noreferrer">result</a></p>
  
  <p>This is what I came up after hours of research and attempts:</p>
  
  <pre><code>MATCH lineage = (n:Sample {name:"P"})-[:CHILD_OF*]-&gt;(parent:Sample)
  MATCH (parent)-[r_out]-&gt;(child)-[r_in]-&gt;(parent)
  WHERE parent IN nodes(lineage) OR child IN nodes(lineage) 
  RETURN
  collect(DISTINCT parent) AS nodes,
  collect({ source: parent.name, rel: type(r_out), target: child.name }) AS links_out,
  collect({ source: child.name, rel: type(r_in), target: parent.name }) AS links_in;
  </code></pre>
  
  <p>(I created two different list of relationships so i can distinguish the source and target.)</p>
  
  <p>However this does not return n in the list of nodes and actually multiplicates the links, as I guess returns all the possible paths between <code>n</code> and all the other nodes.</p>
  
  <p>I could not figure out a solution and I am also convinced it should be a much more elegant query...</p>
  
  <p>Any help?
  Thanks</p>