title: Calculate route laps with Neo4j and cypher
body: <p>I'm new to Neo4j and just investigating whether it fits my needs. Having the following graph:</p>
  
  <pre><code>CREATE (a:Stop {name: 'A'})-[:ROUTE {dist: 1}]-&gt;(b:Stop {name: 'B'})
  CREATE (a)-[:ROUTE {dist: 4}]-&gt;(c:Stop {name: 'C'})
  CREATE (a)-[:ROUTE {dist: 10}]-&gt;(d:Stop {name: 'D'})
  CREATE (b)-[:ROUTE {dist: 3}]-&gt;(e:Stop {name: 'E'})
  CREATE (c)-[:ROUTE {dist: 4}]-&gt;(d)
  CREATE (c)-[:ROUTE {dist: 2}]-&gt;(f:Stop {name: 'F'})
  CREATE (d)-[:ROUTE {dist: 1}]-&gt;(e)
  CREATE (e)-[:ROUTE {dist: 3}]-&gt;(b)
  CREATE (e)-[:ROUTE {dist: 2}]-&gt;(a)
  CREATE (f)-[:ROUTE {dist: 1}]-&gt;(d)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/FLCeK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FLCeK.png" alt="enter image description here"></a></p>
  
  <p>How can I create say some bicycle routes which are limited to a specified mileage? Say I want to get all possible routes from 'E' to 'E' with an overall mileage of less than 16 with the allowance of duplication of any node to node relationships. The result should be something like this:</p>
  
  <p><code>
      |---------------|---------|
      | Route         | Mileage |
      |---------------|---------|
      | E-A-B-E       |   6     |
      | E-A-B-E-B-E   |   15    |
      | E-A-B-E-A-B-E |   12    |
      | ...           |         |
  </code></p>
  
  <p>The main point is to get duplication of routes, the laps, like E-A-B-E-A-B-E. Is this possible to do with cypher only or there is a better approach like getting all the unique routes by cypher and then calculate possible laps somehow on the backend? From my experiments, I couldn't make cypher to traverse the same nodes twice or more time.</p>