2010/9/28 Joshi Hemant - hjoshi <hemant.jo...@acxiom.com> > On second thought, you could use the new traversal framework as well. I > haven't used all the features but it should be possible to do something > like: > TraversalDescription td = > Traversal.description().breadthFirst().relationships( > relation_1, Direction.OUTGOING ).relationships( > relation_2, Direction.OUTGOING).filter( > Traversal.returnAllButStartNode() ); > > I think it will do relation_1 nodes first and then traverse to > relation_2 nodes from those in a breadth_first manner. > -Hemant >
That traverser will traverse both relation_1 and relation_2 on all levels, wherever it is. This kind of functionality is planned for the next iteration of the traversal framework. One not-so-funny-solution would be to do this manually with Node#getRelationships manually and use different types for each level. Node start = ...; for ( Relationship relL1 : start.getRelationships( relation_1 ) ) { Node nodeL1 = relL1.getOtherNode( start ); for ( Relationship relL2 : nodeL1.getRelationships( relation_2 ) ) { Node nodeL2 = relL2.getOtherNode( nodeL1 ); ..... } } > > -----Original Message----- > From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] > On Behalf Of Joshi Hemant - hjoshi > Sent: Tuesday, September 28, 2010 9:42 AM > To: Neo4j user discussions > Subject: Re: [Neo4j] traversing-functionality > > Have you looked at PatternMatch functionality? Take a look at > http://components.neo4j.org/neo4j-graph-matching/ > IMO, you can define a pattern for relation_1 and from what you get as > pattern nodes in relation_1, define relation_2 for them. > > Only thing you will need to know is where to look for such a pattern in > the graph (i.e. start node). If you do not know the start node and want > to want generic pattern, scan over entire graph using (Node n : > graphDb.getAllNodes()) and repeat PatternMatch with each node as a > starting point. > > -Hemant > > -----Original Message----- > From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] > On Behalf Of Konstanze.Lorenz > Sent: Tuesday, September 28, 2010 8:36 AM > To: user@lists.neo4j.org > Subject: [Neo4j] traversing-functionality > > Hi, > For the project I'm working on, I need a traversing as follows: > the relationships, which are put in for the traversing should not be > attended at the same depth. > That means: At first I want to get all nodes by traversing relation_1 > and then on this sample space I want to get all nodes by traversing > relation_2. > BUT: > Traversal.description.expand(Traversal.expanderForTypes(Relation_1,Direc > tion.Outgoing, Relation_2,Direction.Outgoing) > traverses over all nodes with relation_1 and relation_2. > > By now, I didn't find this functionality implemented - has someone a > hint where I can get it (if already existent) or an idea how to > implement it in a reasonable way? > > _______________________________________________ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ************************************************************************ > *** > The information contained in this communication is confidential, is > intended only for the use of the recipient named above, and may be > legally > privileged. > > If the reader of this message is not the intended recipient, you are > hereby notified that any dissemination, distribution or copying of this > communication is strictly prohibited. > > If you have received this communication in error, please resend this > communication to the sender and delete the original message or any copy > of it from your computer system. > > Thank You. > ************************************************************************ > **** > > _______________________________________________ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > _______________________________________________ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > -- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user