Neo4j: all paths between two entities (unclear performance)
<p>I am using Neo4j Version: 2.3.3. I am trying to find all paths between two entities eg.,:</p>

<p><strong>(Edit)</strong></p>

<pre><code>PathExpander&lt;Object&gt; expander =   Traversal.pathExpanderForAllTypes(Reldir);  
PathFinder&lt;Path&gt; finder = GraphAlgoFactory.allPaths(expander, depth); 
Iterator&lt;Path&gt; paths = finder.findAllPaths(first_node, second_node).iterator();

 while (paths.hasNext()) {

        Path path = paths.next();
            . . .
}
</code></pre>

<p>The result (example):</p>

<pre><code> "Entity: A"  "Number of paths: 16" "Longest path: 11" "Calculation: Time:  1.0 Millseconds" 
 "Entity: B"  "Number of paths: 1"   "Longest path: 3" "Calculation: Time:  2.6 Millseconds" 
</code></pre>

<p>However, I have noticed that it is not always the case that the number of paths or the longest path play a role in the performance. For example:</p>

<pre><code>   A--&gt;b--&gt;c--&gt;D can be much faster than finding the path for A--&gt;B
</code></pre>

<p>and also if the number of paths between A-->D is 10 can be much faster if the number of path between A-->D is only 4.
I expected that the number of paths and the path length will play a strong role in the performance.</p>

<p>Any explanation why such behaviour?  </p>

<p>In contrast when I am interested to compute how many relationships are associated with one entity, I can see that there is dependences between the number of relationships and the computation time.  </p>