Package org.neo4j.graphdb.traversal

Examples of org.neo4j.graphdb.traversal.TraversalDescription


    private static TraversalDescription traversal( TraverserImpl traverser,
            Order order, StopEvaluator stopEvaluator,
            ReturnableEvaluator returnableEvaluator )
    {
        TraversalDescription description = BASE_DESCRIPTION;
        switch ( order )
        {
        case BREADTH_FIRST:
            description = description.breadthFirst();
            break;
        case DEPTH_FIRST:
            description = description.depthFirst();
            break;

        default:
            throw new IllegalArgumentException( "Onsupported traversal order: "
                                                + order );
        }

        description = description.prune( new Pruner( traverser, stopEvaluator ) );
        description = description.filter( new Filter( traverser,
                returnableEvaluator ) );

        return description;
    }
View Full Code Here


                return IteratorUtil.count( path.endNode().getRelationships( Direction.OUTGOING ).iterator() ) < 3 ?
                        Evaluation.INCLUDE_AND_PRUNE : Evaluation.INCLUDE_AND_CONTINUE;
            }
        };
       
        TraversalDescription description = Traversal.description().evaluator( Evaluators.all() )
                .evaluator( Evaluators.toDepth( 1 ) ).evaluator( lessThanThreeRels );
        Set<String> expectedNodes = new HashSet<String>(
                Arrays.asList( "a", "b", "c", "d", "e" ) );
        for ( Path position : description.traverse( referenceNode() ) )
        {
            String name = (String) position.endNode().getProperty( "name" );
            assertTrue( name + " shouldn't have been returned", expectedNodes.remove( name ) );
        }
        assertTrue( expectedNodes.isEmpty() );
View Full Code Here

            {
                return Evaluation.ofIncludes( IteratorUtil.count( path.endNode().getRelationships( Direction.OUTGOING ) ) <= 2 );
            }
        };
       
        TraversalDescription description = Traversal.description().evaluator( mustBeConnectedToK );
        expectNodes( description.traverse( referenceNode() ), "b", "c" );
        expectNodes( description.evaluator( mustNotHaveMoreThanTwoOutRels ).traverse( referenceNode() ), "c" );
    }
View Full Code Here

            nodes.add( node );
            return nodes;
        }
        try
        {
            TraversalDescription description = gsm.isRemote() ? RestTraversal.description().maxDepth( depth ) : Traversal.description().evaluator( Evaluators.toDepth( depth ) );
            description.breadthFirst().evaluator( Evaluators.all() );
            relTypes.clear();
            for ( DirectedRelationship directedRel : directedRels )
            {
                Direction d = directedRel.hasDirection() ?  directedRel.getDirection() : Direction.BOTH;
                description.relationships( directedRel.getRelType(), d );
                relTypes.add( directedRel.getRelType() );
            }
            for ( Node currentNode : description.traverse( node ).nodes() )
            {
                if ( nodes.size() >= nodeLimit )
                {
                    break;
                }
View Full Code Here

    private static final int MAXIMUM_DEPTH = 5;
    public Collection<RatedRestaurant> getTopNRatedRestaurants(final UserAccount user, final int n) {
        final CalculateRatingPredicate calculateRatingPredicate = new CalculateRatingPredicate();
        final Node userNode=user.getPersistentState();
        final TraversalDescription traversalDescription = new TraversalDescriptionImpl()
                .order(Traversal.postorderBreadthFirst())
                .prune(Traversal.pruneAfterDepth(MAXIMUM_DEPTH))
                .filter(calculateRatingPredicate)
                .relationships(DynamicRelationshipType.withName("friends"));
        final Traverser traverser = traversalDescription.traverse(userNode);
        final Iterator<Node> it = traverser.nodes().iterator();
        while (it.hasNext()) {
            it.next();
        }
        return calculateRatingPredicate.getRecommendedRestaurants(n);
View Full Code Here

        return worldRepository.findAllByPropertyValue("moon-index", "moons", moonCount);
    }

    @Override
    public Iterable<World> exploreWorldsBeyond(World homeWorld) {
        TraversalDescription traversal = Traversal.description().relationships(withName(REACHABLE_BY_ROCKET), Direction.OUTGOING);
        return worldRepository.findAllByTraversal(homeWorld, traversal);
    }
View Full Code Here

TOP

Related Classes of org.neo4j.graphdb.traversal.TraversalDescription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.