title: Finding right path in Cypher Neo4j
body: <p>I'm working with Flight Analyzer database (<a href="https://neo4j.com/graphgist/flight-analyzer" rel="nofollow noreferrer">https://neo4j.com/graphgist/flight-analyzer</a>).
  We have there few nodes and relationships types.
  Nodes: 
  Airport</p>
  
  <pre><code>(SEA:Airport { name:'SEA' })
  </code></pre>
  
  <p>Flight</p>
  
  <pre><code>(f0:Flight { date:'11/30/2015 04:24:12', duration:218, distance:1721, airline:'19977' })
  </code></pre>
  
  <p>Ticket</p>
  
  <pre><code>(t1f0:Ticket { class:'economy', price:1344.75 })
  </code></pre>
  
  <p>Relationships
  Destination</p>
  
  <pre><code>(f0)-[:DESTINATION]-&gt;(ORD)
  </code></pre>
  
  <p>Origin</p>
  
  <pre><code>(f0)-[:ORIGIN]-&gt;(SEA)
  </code></pre>
  
  <p>Assign</p>
  
  <pre><code>(t1f0)-[:ASSIGN]-&gt;(f0)
  </code></pre>
  
  <p>Now I need to find some path and I have problem with that connection ORIGIN - FLIGHT - DESTINATION.
  I need to find all airports that are connected to LAX airport with sum of ticket prices &lt; 3000.</p>
  
  <p>I tried</p>
  
  <pre><code>MATCH path = (origin:Airport { name:"LAX" })&lt;-[r:ORIGIN|DESTINATION*..5]-&gt;(destination:Airport)
  WHERE REDUCE(s = 0, n IN [x IN NODES(path) WHERE 'Flight' IN LABELS(x)] |
  s + [(n)&lt;-[:ASSIGN]-(ticket) | ticket.price][0]
  ) &lt; 3000
  RETURN path
  </code></pre>
  
  <p>but in this solution LAX can be ORIGIN and DESTINATION too. I only want to chose paths that always have the same order aiport1 &lt;- origin - flight1 - destination -> airport2 &lt;- origin - flight2 - destination -> aiport etc..</p>
  
  <p>I need to include departure and arrive time so
  flight1 date + duration &lt; flight2 date then flight2 date + duration &lt; flight3 date etc...</p>