Search in sources :

Example 1 with MonoDirectionalTraversalDescription

use of org.neo4j.kernel.impl.traversal.MonoDirectionalTraversalDescription in project neo4j by neo4j.

the class Dijkstra method traverser.

private Traverser traverser(Node start, final Node end, PathInterest<Double> interest) {
    PathExpander dijkstraExpander;
    PathEvaluator dijkstraEvaluator;
    if (stateInUse) {
        dijkstraExpander = expander;
        dijkstraEvaluator = Evaluators.includeWhereEndNodeIs(end);
    } else {
        MutableDouble shortestSoFar = new MutableDouble(Double.MAX_VALUE);
        dijkstraExpander = new DijkstraPathExpander(expander, shortestSoFar, epsilon, interest.stopAfterLowestCost());
        dijkstraEvaluator = new DijkstraEvaluator(shortestSoFar, end, costEvaluator);
    }
    lastTraverser = new MonoDirectionalTraversalDescription().uniqueness(Uniqueness.NODE_PATH).expand(dijkstraExpander, stateFactory).order(new DijkstraSelectorFactory(interest, costEvaluator)).evaluator(dijkstraEvaluator).traverse(start);
    return lastTraverser;
}
Also used : PathEvaluator(org.neo4j.graphdb.traversal.PathEvaluator) MutableDouble(org.apache.commons.lang3.mutable.MutableDouble) MonoDirectionalTraversalDescription(org.neo4j.kernel.impl.traversal.MonoDirectionalTraversalDescription) PathExpander(org.neo4j.graphdb.PathExpander) DijkstraSelectorFactory(org.neo4j.graphalgo.impl.util.DijkstraSelectorFactory)

Example 2 with MonoDirectionalTraversalDescription

use of org.neo4j.kernel.impl.traversal.MonoDirectionalTraversalDescription in project neo4j by neo4j.

the class TestBestFirstSelectorFactory method shouldDoWholeTraversalInCorrectOrder.

@Test
public void shouldDoWholeTraversalInCorrectOrder() {
    Node a = graph.getNode("a");
    Traverser traverser = new MonoDirectionalTraversalDescription().expand(expander).order(factory).uniqueness(uniqueness).traverse(a);
    ResourceIterator<Path> iterator = traverser.iterator();
    int i = 0;
    while (iterator.hasNext()) {
        assertPath(iterator.next(), expectedResult[i]);
        i++;
    }
    assertEquals(String.format("Not all expected paths where traversed. Missing paths are %s\n", Arrays.toString(Arrays.copyOfRange(expectedResult, i, expectedResult.length))), expectedResult.length, i);
}
Also used : Path(org.neo4j.graphdb.Path) Node(org.neo4j.graphdb.Node) Traverser(org.neo4j.graphdb.traversal.Traverser) MonoDirectionalTraversalDescription(org.neo4j.kernel.impl.traversal.MonoDirectionalTraversalDescription) Test(org.junit.Test)

Example 3 with MonoDirectionalTraversalDescription

use of org.neo4j.kernel.impl.traversal.MonoDirectionalTraversalDescription in project neo4j by neo4j.

the class TraversalDescriptionBuilder method from.

public TraversalDescription from(Map<String, Object> description) {
    try {
        TraversalDescription result = new MonoDirectionalTraversalDescription();
        result = describeOrder(result, description);
        result = describeUniqueness(result, description);
        result = describeExpander(result, description);
        result = describePruneEvaluator(result, description);
        result = describeReturnFilter(result, description);
        return result;
    } catch (NoClassDefFoundError e) {
        // the backported javax.script jar file(s) on the classpath.
        throw new EvaluationException(e);
    }
}
Also used : MonoDirectionalTraversalDescription(org.neo4j.kernel.impl.traversal.MonoDirectionalTraversalDescription) TraversalDescription(org.neo4j.graphdb.traversal.TraversalDescription) MonoDirectionalTraversalDescription(org.neo4j.kernel.impl.traversal.MonoDirectionalTraversalDescription)

Aggregations

MonoDirectionalTraversalDescription (org.neo4j.kernel.impl.traversal.MonoDirectionalTraversalDescription)3 MutableDouble (org.apache.commons.lang3.mutable.MutableDouble)1 Test (org.junit.Test)1 DijkstraSelectorFactory (org.neo4j.graphalgo.impl.util.DijkstraSelectorFactory)1 Node (org.neo4j.graphdb.Node)1 Path (org.neo4j.graphdb.Path)1 PathExpander (org.neo4j.graphdb.PathExpander)1 PathEvaluator (org.neo4j.graphdb.traversal.PathEvaluator)1 TraversalDescription (org.neo4j.graphdb.traversal.TraversalDescription)1 Traverser (org.neo4j.graphdb.traversal.Traverser)1