Search in sources :

Example 1 with StandardBranchCollisionDetector

use of org.neo4j.graphdb.impl.traversal.StandardBranchCollisionDetector in project neo4j by neo4j.

the class TestBidirectionalTraversal method mirroredTraversalReversesInitialState.

@Test
public void mirroredTraversalReversesInitialState() throws Exception {
    /*
         * (a)-->(b)-->(c)-->(d)
         */
    createGraph("a TO b", "b TO c", "c TO d");
    BranchCollisionPolicy collisionPolicy = new BranchCollisionPolicy() {

        @Override
        public BranchCollisionDetector create(Evaluator evaluator, Predicate<Path> pathPredicate) {
            return new StandardBranchCollisionDetector(null, null) {

                @Override
                protected boolean includePath(Path path, TraversalBranch startPath, TraversalBranch endPath) {
                    assertEquals(0, startPath.state());
                    assertEquals(10, endPath.state());
                    return true;
                }
            };
        }
    };
    Iterables.count(getGraphDb().bidirectionalTraversalDescription().mirroredSides(getGraphDb().traversalDescription().uniqueness(NODE_PATH).expand(PathExpanders.<Integer>forType(to), new InitialBranchState.State<>(0, 10))).collisionPolicy(collisionPolicy).traverse(getNodeWithName("a"), getNodeWithName("d")));
}
Also used : Path(org.neo4j.graphdb.Path) BranchCollisionPolicy(org.neo4j.graphdb.traversal.BranchCollisionPolicy) InitialBranchState(org.neo4j.graphdb.traversal.InitialBranchState) StandardBranchCollisionDetector(org.neo4j.graphdb.impl.traversal.StandardBranchCollisionDetector) Evaluator(org.neo4j.graphdb.traversal.Evaluator) TraversalBranch(org.neo4j.graphdb.traversal.TraversalBranch) Predicate(java.util.function.Predicate) Test(org.junit.Test)

Aggregations

Predicate (java.util.function.Predicate)1 Test (org.junit.Test)1 Path (org.neo4j.graphdb.Path)1 StandardBranchCollisionDetector (org.neo4j.graphdb.impl.traversal.StandardBranchCollisionDetector)1 BranchCollisionPolicy (org.neo4j.graphdb.traversal.BranchCollisionPolicy)1 Evaluator (org.neo4j.graphdb.traversal.Evaluator)1 InitialBranchState (org.neo4j.graphdb.traversal.InitialBranchState)1 TraversalBranch (org.neo4j.graphdb.traversal.TraversalBranch)1