How can I calculate the path between two nodes with hops in range (1,5) (neo4j) ?
<p>I'm trying to find all possible path between two nodes. I've used few cypher queries which does the required job but it take a lot of time if the hops increases. This is the query</p>

<pre><code>match p = (n{name:"Node1"})-[:Route*1..5]-(b{name:"Node2"}) return p
</code></pre>

<p>Also if I use <code>shortestpath</code> it limits the result if a path with minimum hop is found. So I don't get the results with 2 or more than two hops if a direct connection (1 hop) is found between the nodes.</p>

<pre><code>match p = shortestpath((n{name:"Node1"})-[:Route*1..5]-(b{name:"Node2"})) return p
</code></pre>

<p>and if I increase the hop to 2 or more it throws an exception.</p>

<pre><code>shortestPath(...) does not support a minimal length different from 0 or 1 
</code></pre>

<p>Is there any other alternative framework or algorithm to get all path with minimum time ?</p>

<p>P.S. I'm looking for something in the order of ms. Currently all queries with hops greater than 3 takes few seconds to complete.</p>