Reputation: 91
I'm a starter in neo4j and I wanna know if is possible find best paths using neo4j, where I have a cost, but I wanna first best path, and second best path and so on...
If I have 3 possible paths I need get all 3 in ordered by cost, if I have 100 possible paths I need limit the results too (for example, top 10 results).
This is possible in neo4j?
PS: in my tests I used java-astar-routing sample: https://github.com/neo4j-examples/java-astar-routing
Thanks and sorry for my poor english ;),
Upvotes: 1
Views: 327
Reputation: 3054
You could also write your own traverser using a best-first ordering policy. Something like:
Traversal.traversal()
.order( new MyOwnBestFirstOrdering() )
...
.traverse( startNode );
class MyOwnBestFirstOrdering extends BestFirstSelectorFactory<Integer,Integer>
{
@Override public Integer startData() {
return 0;
}
...
}
Upvotes: 0
Reputation: 1685
Basically, what you want is ALL the paths between two nodes, then calculate their weights, and then sort them by cost.
The latter two bits are quite easy to do, now all you need is to find all the paths :
Upvotes: 2