That information is not available at the moment. But it is an interesting
idea. How would you like to access it? Can you give a quick sketch of how
you envision the API for it.
Would it be something like this?
interface PathFinderP extends Path {
P findSinglePath( Node start, Node end ); // ok, nothing added here
// you'd have to use this version to get those statistics:
CountIterableP findAllPaths( Node start, Node end );
}
interface CountIterableT extends IterableT {
CountIteratorT iterator();
}
interface CountIteratorT extends IteratorT {
int numberOfNodesVisitedSoFar();
int numberOfRelationshipsVisitedSoFar();
}
(But with more thought through names)
Since computation isn't performed until actually requested (when the
iterator is iterated over), and since the Iterable could give a different
result when you iterate over it subsequent times (due to the graph being
modified), the Iterator object is the only object where I could see that
such information could be added usefully. This does mean that you cannot use
the java foreach loop with such an Iterable AND get the visited count, but
would have to resort to using the hasNext() and next() methods. We could
quite easily add some convenience methods for making that easier though,
something like:
CountIteratorPath pathIter = shortestPath.findAllPaths( start, end
).iterator();
for ( Path path : IterUtil.loop( pathIter ) ) {
doSomethingWith(path);
}
// after the loop is done, number of nodes visited so far is the total
number of visited nodes.
int visitedNodes = pathIter.numberOfNodesVisitedSoFar();
WDYT? If this is useful we could add this kind of statistics to all types of
traversals. Exposing that through the REST interface would be even simpler,
the implementation would simply do the equivalent of the iteration above
then add the statistics to the result. For paginated results (when those are
added) we could have the statistics reflect the number of nodes visited for
creating that page of data, for algorithms that find the easiest solutions
first, you could use those statistics to stop a search when the number of
nodes visited to collect a page grows too big.
Cheers,
Tobias
PS. I had a few other ideas on how such statistics information could be
added, but this was the least invasive of them. I sketched this up in five
minutes (after half a bottle of wine), so I'm very open to the possibility
of there being more elegant ways of adding this information.
On Sun, Apr 10, 2011 at 10:45 PM, Stephan Hagemann
stephan.hagem...@googlemail.com wrote:
Hi all,
is there a way for me to get to the number of nodes or relationships that
the graph algorithms (like ShortestPath) have visited and output it with
the
result of the query? I would like to do that to analyze the performance and
load of query processing. Any ideas?
Thanks!
Stephan
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user
--
Tobias Ivarsson tobias.ivars...@neotechnology.com
Hacker, Neo Technology
www.neotechnology.com
Cellphone: +46 706 534857
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user