Search in sources :

Example 1 with WeightedPathIterator

use of org.neo4j.graphalgo.impl.util.WeightedPathIterator in project neo4j by neo4j.

the class TraversalAStar method findPaths.

private Iterable<WeightedPath> findPaths(Node start, Node end, boolean multiplePaths) {
    PathInterest interest;
    if (multiplePaths) {
        interest = stopAfterLowestWeight ? PathInterestFactory.allShortest() : PathInterestFactory.all();
    } else {
        interest = PathInterestFactory.single();
    }
    GraphDatabaseService db = start.getGraphDatabase();
    TraversalDescription traversalDescription = db.traversalDescription().uniqueness(Uniqueness.NONE).expand(expander, initialState);
    lastTraverser = traversalDescription.order(new SelectorFactory(end, interest)).evaluator(includeWhereEndNodeIs(end)).traverse(start);
    return new Iterable<WeightedPath>() {

        @Override
        public Iterator<WeightedPath> iterator() {
            return new WeightedPathIterator(lastTraverser.iterator(), costEvaluator, stopAfterLowestWeight);
        }
    };
}
Also used : WeightedPathIterator(org.neo4j.graphalgo.impl.util.WeightedPathIterator) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) WeightedPath(org.neo4j.graphalgo.WeightedPath) BestFirstSelectorFactory(org.neo4j.graphalgo.impl.util.BestFirstSelectorFactory) PathInterest(org.neo4j.graphalgo.impl.util.PathInterest) TraversalDescription(org.neo4j.graphdb.traversal.TraversalDescription)

Aggregations

WeightedPath (org.neo4j.graphalgo.WeightedPath)1 BestFirstSelectorFactory (org.neo4j.graphalgo.impl.util.BestFirstSelectorFactory)1 PathInterest (org.neo4j.graphalgo.impl.util.PathInterest)1 WeightedPathIterator (org.neo4j.graphalgo.impl.util.WeightedPathIterator)1 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)1 TraversalDescription (org.neo4j.graphdb.traversal.TraversalDescription)1