title: How to query exact path in neo4j and avoid cartesian product?
body: <p>I have around 3000 nodes with 7000 relationships in a graph but for a presentation, I'd like to plot a sub-graph of which I know exactly which nodes I need.</p>
  
  <p>Therefore, I use the following query which sometimes gives me the correct path as a result (after a long waiting period) and sometimes depletes memory and cpu resources until I force-quit the neo4j-browser.</p>
  
  <pre><code>MATCH p1=(:DestinationNode)-[:IS_AT]-&gt;
  (:CentiDegreeNode{x: 4714, y: 843})-[:CONNECTED_TO*1]-
  (:CentiDegreeNode{x: 4715, y: 843})-[:CONNECTED_TO*1]-
  (:CentiDegreeNode{x: 4716, y: 843})-[:CONNECTED_TO*1]-
  (:CentiDegreeNode{x: 4717, y: 843})-[:CONNECTED_TO*1]-
  (:CentiDegreeNode{x: 4718, y: 843})-[:CONNECTED_TO*1]-
  (:CentiDegreeNode{x: 4718, y: 844})-[:CONNECTED_TO*1]-
  (:CentiDegreeNode{x: 4719, y: 844}),
  p2=(:DestinationNode)-[:IS_AT]-&gt;
  (:CentiDegreeNode{x: 4718, y: 839})-[:CONNECTED_TO*1]-
  (:CentiDegreeNode{x: 4718, y: 840})-[:CONNECTED_TO*1]-
  (:CentiDegreeNode{x: 4719, y: 840})-[:CONNECTED_TO*1]-
  (:CentiDegreeNode{x: 4719, y: 841})-[:CONNECTED_TO*1]-
  (:CentiDegreeNode{x: 4719, y: 842})-[:CONNECTED_TO*1]-
  (:CentiDegreeNode{x: 4719, y: 843})-[:CONNECTED_TO*1]-
  (:CentiDegreeNode{x: 4719, y: 844}),
  p3=(:CentiDegreeNode{x: 4719, y: 844})-[:CONNECTED_TO*1]-
  (:CentiDegreeNode{x: 4719, y: 845})-[:CONNECTED_TO*1]-
  (:CentiDegreeNode{x: 4719, y: 846})
  RETURN p1, p2, p3
  </code></pre>
  
  <p>What am I doing wrong? How would I have to rephrase the query in order to have it executed within seconds? Note that <code>x</code> and <code>y</code> of a <code>CentiDegreeNode</code> are indexed.</p>
  
  <p>Initially I started with directed relationships (<code>-[:CONNECTED_TO]-&gt;</code>) but this wasn't any quicker. </p>
  
  <p>Thank you very much!</p>