Search in sources :

Example 1 with StopAfterWeightIterator

use of org.neo4j.graphalgo.impl.util.StopAfterWeightIterator in project neo4j-mobile-android by neo4j-contrib.

the class ExperimentalAStar method findAllPaths.

public Iterable<WeightedPath> findAllPaths(Node start, final Node end) {
    Predicate<Path> filter = new Predicate<Path>() {

        public boolean accept(Path position) {
            return position.endNode().equals(end);
        }
    };
    final Traverser traverser = traversalDescription.order(new SelectorFactory(end)).filter(filter).traverse(start);
    return new Iterable<WeightedPath>() {

        public Iterator<WeightedPath> iterator() {
            return new StopAfterWeightIterator(traverser.iterator(), costEvaluator);
        }
    };
}
Also used : Path(org.neo4j.graphdb.Path) WeightedPath(org.neo4j.graphalgo.WeightedPath) WeightedPath(org.neo4j.graphalgo.WeightedPath) BestFirstSelectorFactory(org.neo4j.graphalgo.impl.util.BestFirstSelectorFactory) Traverser(org.neo4j.graphdb.traversal.Traverser) StopAfterWeightIterator(org.neo4j.graphalgo.impl.util.StopAfterWeightIterator) Predicate(org.neo4j.helpers.Predicate)

Example 2 with StopAfterWeightIterator

use of org.neo4j.graphalgo.impl.util.StopAfterWeightIterator in project neo4j-mobile-android by neo4j-contrib.

the class Dijkstra method findAllPaths.

public Iterable<WeightedPath> findAllPaths(Node start, final Node end) {
    Predicate<Path> filter = new Predicate<Path>() {

        public boolean accept(Path position) {
            return position.endNode().equals(end);
        }
    };
    final Traverser traverser = TRAVERSAL.expand(expander).order(new SelectorFactory(costEvaluator)).filter(filter).traverse(start);
    return new Iterable<WeightedPath>() {

        public Iterator<WeightedPath> iterator() {
            return new StopAfterWeightIterator(traverser.iterator(), costEvaluator);
        }
    };
}
Also used : Path(org.neo4j.graphdb.Path) WeightedPath(org.neo4j.graphalgo.WeightedPath) WeightedPath(org.neo4j.graphalgo.WeightedPath) BestFirstSelectorFactory(org.neo4j.graphalgo.impl.util.BestFirstSelectorFactory) Traverser(org.neo4j.graphdb.traversal.Traverser) StopAfterWeightIterator(org.neo4j.graphalgo.impl.util.StopAfterWeightIterator) Predicate(org.neo4j.helpers.Predicate)

Example 3 with StopAfterWeightIterator

use of org.neo4j.graphalgo.impl.util.StopAfterWeightIterator in project graphdb by neo4j-attic.

the class Dijkstra method findAllPaths.

public Iterable<WeightedPath> findAllPaths(Node start, final Node end) {
    Predicate<Path> filter = new Predicate<Path>() {

        public boolean accept(Path position) {
            return position.endNode().equals(end);
        }
    };
    final Traverser traverser = TRAVERSAL.expand(expander).order(new SelectorFactory(costEvaluator)).filter(filter).traverse(start);
    return new Iterable<WeightedPath>() {

        public Iterator<WeightedPath> iterator() {
            return new StopAfterWeightIterator(traverser.iterator(), costEvaluator);
        }
    };
}
Also used : Path(org.neo4j.graphdb.Path) WeightedPath(org.neo4j.graphalgo.WeightedPath) WeightedPath(org.neo4j.graphalgo.WeightedPath) BestFirstSelectorFactory(org.neo4j.graphalgo.impl.util.BestFirstSelectorFactory) Traverser(org.neo4j.graphdb.traversal.Traverser) StopAfterWeightIterator(org.neo4j.graphalgo.impl.util.StopAfterWeightIterator) Predicate(org.neo4j.helpers.Predicate)

Example 4 with StopAfterWeightIterator

use of org.neo4j.graphalgo.impl.util.StopAfterWeightIterator in project graphdb by neo4j-attic.

the class ExperimentalAStar method findAllPaths.

public Iterable<WeightedPath> findAllPaths(Node start, final Node end) {
    Predicate<Path> filter = new Predicate<Path>() {

        public boolean accept(Path position) {
            return position.endNode().equals(end);
        }
    };
    final Traverser traverser = traversalDescription.order(new SelectorFactory(end)).filter(filter).traverse(start);
    return new Iterable<WeightedPath>() {

        public Iterator<WeightedPath> iterator() {
            return new StopAfterWeightIterator(traverser.iterator(), costEvaluator);
        }
    };
}
Also used : Path(org.neo4j.graphdb.Path) WeightedPath(org.neo4j.graphalgo.WeightedPath) WeightedPath(org.neo4j.graphalgo.WeightedPath) BestFirstSelectorFactory(org.neo4j.graphalgo.impl.util.BestFirstSelectorFactory) Traverser(org.neo4j.graphdb.traversal.Traverser) StopAfterWeightIterator(org.neo4j.graphalgo.impl.util.StopAfterWeightIterator) Predicate(org.neo4j.helpers.Predicate)

Aggregations

WeightedPath (org.neo4j.graphalgo.WeightedPath)4 BestFirstSelectorFactory (org.neo4j.graphalgo.impl.util.BestFirstSelectorFactory)4 StopAfterWeightIterator (org.neo4j.graphalgo.impl.util.StopAfterWeightIterator)4 Path (org.neo4j.graphdb.Path)4 Traverser (org.neo4j.graphdb.traversal.Traverser)4 Predicate (org.neo4j.helpers.Predicate)4