Package org.neo4j.graphdb.traversal

Examples of org.neo4j.graphdb.traversal.Traverser


           @Test
           public void compareIndexAndTraversal() throws Exception {
             IndexManager index = graphDb.index();            
             Index<Node> goodGuys = index.forNodes("heroes");
             IndexHits<Node> hits = goodGuys.query( "name", "*" );           
             Traverser heroesTraverser = getHeroes();              
               assertEquals( heroesTraverser.nodes().iterator().next().getId(), hits.iterator().next().getId() );
           }
View Full Code Here


           }
          
          
           @Test
           public void checkTraverseByProperties() throws Exception {       
               Traverser heroesTraverser = getHeroes();
               Traverser heroesTraverserByProperties = getHeroesByNodeProperties();
               assertEquals( heroesTraverser.nodes().iterator().next(), heroesTraverserByProperties.nodes().iterator().next() );
           }
View Full Code Here

            * @throws Exception
            */
           @Test
           public void findCypher() throws Exception{
             Node neoNode = mdg.getNeoNode();             
               Traverser friendsTraverser = getFriends( neoNode );
               boolean foundCypher = false;
               for ( Path friendPath : friendsTraverser ) {               
                 if (friendPath.endNode().getProperty("name").equals("Cypher")){
                   foundCypher = true;
                   break;
View Full Code Here

            */
           @Test
           public void getMatrixHackers() throws Exception
           {

                   Traverser traverser = findHackers( mdg.getNeoNode() );
                   int numberOfHackers = 0;
                   for ( Path hackerPath : traverser ) {
                       numberOfHackers++;
                   }
                   assertEquals( 1, numberOfHackers );
View Full Code Here

    @Test
    public void testTraverseToNeighbour() {
        final Relationship rel = relationship();
        final TraversalDescription traversalDescription = RestTraversal.description().maxDepth(1).breadthFirst();
        System.out.println("traversalDescription = " + traversalDescription);
        final Traverser traverser = traversalDescription.traverse(rel.getStartNode());
        final Iterable<Node> nodes = traverser.nodes();
        Assert.assertEquals(rel.getEndNode(), nodes.iterator().next());
    }
View Full Code Here

        final TraversalDescription traversalDescription = new TraversalDescriptionImpl()
                .order(Traversal.postorderBreadthFirst())
                .evaluator(Evaluators.toDepth(MAXIMUM_DEPTH))
                .evaluator(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 new LiteDepthFirstSelector( startSource,
                                startThreshold );
                    }
                } );
        final int firstHalf = onDepth / 2;
        Traverser startTraverser = base.prune(
                Traversal.pruneAfterDepth( firstHalf ) ).expand(
                expander ).filter( new Predicate<Path>()
        {
            public boolean accept( Path item )
            {
                return item.length() == firstHalf;
            }
        } ).traverse( start );
        final int secondHalf = onDepth - firstHalf;
        Traverser endTraverser = base.prune(
                Traversal.pruneAfterDepth( secondHalf ) ).expand(
                expander.reversed() ).filter( new Predicate<Path>()
        {
            public boolean accept( Path item )
            {
                return item.length() == secondHalf;
            }
        } ).traverse( end );

        final Iterator<Path> startIterator = startTraverser.iterator();
        final Iterator<Path> endIterator = endTraverser.iterator();

        final Map<Node, Visit> visits = new HashMap<Node, Visit>();
        return new PrefetchingIterator<Path>()
        {
            @Override
View Full Code Here

            {
                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 );
            }
        };
    }
View Full Code Here

            {
                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 );
            }
        };
    }
View Full Code Here

        execute( Traversal.description().breadthFirst(), Uniqueness.RELATIONSHIP_RECENT );
    }

    private void execute( TraversalDescription traversal, Uniqueness uniqueness )
    {
        Traverser traverser = traversal.uniqueness( uniqueness ).traverse(
                referenceNode() );
        assertFalse( "empty traversal", IteratorUtil.count( traverser ) == 0 );
    }
View Full Code Here

TOP

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

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.