Good point Max, you're right the OrderedType expander doesn't really do that. Did you have a blog posted about that?
Michael On Sat, Jan 25, 2014 at 11:55 PM, Max De Marzi Jr. <[email protected]>wrote: > > Use your own Array Expander: > > RelationshipType[][] orderedRelTypes = { > { Relations.FRIENDS, Relations.ENEMIES }, > { Relations.LIKES }, > { Relations.HATES} > }; > Direction[] directions = {Direction.OUTGOING, > Direction.INCOMING, Direction.INCOMING} ; > > Traverser traverser = Traversal.description() > .depthFirst() > .expand(new ArrayExpander(directions,orderedRelTypes)) > .evaluator(Evaluators.atDepth(3)) > .uniqueness(Uniqueness.NONE) > .traverse(person); > > > public class ArrayExpander implements PathExpander { > > private Direction[] directions; > private RelationshipType[][] types; > > public ArrayExpander(Direction[] directions, RelationshipType[][] > types ) > { > this.types = types; > this.directions = directions; > } > > public Iterable<Relationship> expand(Path path, BranchState state){ > return path.endNode().getRelationships(directions[path.length()], > types[path.length()]); > } > > public ArrayExpander reverse() > { > return new ArrayExpander(directions, types); > } > } > > > > On Saturday, January 25, 2014 12:26:49 PM UTC-6, Javad Karabi wrote: > >> but now, i am seeing that it does traverse ()-[:preferred_store]->()<-[: >> preferred_store]-() >> but, i am seeing that it _again_ traverses out via preferred_store: >> >> (0)--[preferred_store,10]-->(11)<--[preferred_store,3517594]--(90746)--[preferred_store,3517600]-->(19758) >> >> >> even though my expander looks as such: >> PathExpander e = (new org.neo4j.kernel.OrderedByTypeExpander()) >> .add( Rels.preferred_store, Direction.OUTGOING ) >> .add( Rels.preferred_store, Direction.INCOMING ) >> .add( Rels.ordered, Direction.OUTGOING ) >> ; >> >> should this not match only ()-[:preferred_store]->()<-[: >> preferred_store]-()-[:ordered]->() >> ? >> >> >> >> On Sat, Jan 25, 2014 at 12:22 PM, Javad Karabi <[email protected]>wrote: >> >>> scratch that, i forgot to import it... >>> >>> >>> On Sat, Jan 25, 2014 at 12:13 PM, Javad Karabi <[email protected]>wrote: >>> >>>> it does not seem to work for me >>>> >>>> error: cannot find symbol >>>> asList( >>>> ^ >>>> symbol: method asList(Pair<Rels,Direction>) >>>> >>>> >>>> >>>> On Saturday, January 25, 2014 6:59:20 AM UTC-6, Stefan Armbruster wrote: >>>> >>>>> Arrays.asList from the JDK, >>>>> http://docs.oracle.com/javase/7/docs/api/java/util/Arrays.ht >>>>> ml#asList(T...) >>>>> >>>>> 2014/1/25 Javad Karabi <[email protected]>: >>>>> > the asList can not seem to be found... where is that provided? >>>>> > >>>>> > >>>>> > On Friday, January 24, 2014 7:21:37 PM UTC-6, Michael Hunger wrote: >>>>> >> >>>>> >> I think you have to create a custom RelationshipExpander, that >>>>> takes a >>>>> >> list of pairs of type and direction and checks at the current path >>>>> length >>>>> >> for the correct combo to look for. >>>>> >> >>>>> >> I think from a quick look that org.neo4j.kernel.OrderedByTypeExpander >>>>> >>>>> >> already does this btw. Please check. >>>>> >> >>>>> >> new >>>>> >> OrderedByTypeExpander(asList(Pair.of(DynamicRelationshipType.withName("preferred_store"), >>>>> >>>>> >> Direction.OUTGOING),Pair.of( >>>>> >> DynamicRelationshipType.withName("preferred_store"), >>>>> Direction.INCOMING), >>>>> >> ....) >>>>> >> >>>>> >> Michael >>>>> >> >>>>> >> >>>>> >> On Fri, Jan 24, 2014 at 10:21 PM, Javad Karabi <[email protected]> >>>>> wrote: >>>>> >>> >>>>> >>> How would i use the traversal description to do the following? >>>>> >>> >>>>> >>> MATCH >>>>> >>> me-[:preferred_store]->(:Store)<-[:preferred_store]-(:Member >>>>> )-[:ordered]->(p:Product) >>>>> >>> >>>>> >>> I assumed that the following worked: >>>>> >>> .relationships( >>>>> >>> DynamicRelationshipType.withName("preferred_store"), >>>>> Direction.OUTGOING ) >>>>> >>> .relationships( >>>>> >>> DynamicRelationshipType.withName("preferred_store"), >>>>> Direction.INCOMING ) >>>>> >>> .relationships( DynamicRelationshipType.withName("ordered"), >>>>> >>>>> >>> Direction.OUTGOING ) >>>>> >>> .relationships( DynamicRelationshipType.withName("product"), >>>>> >>>>> >>> Direction.OUTGOING ) >>>>> >>> >>>>> >>> However, I am seeing that the order in which relationships() is >>>>> executed >>>>> >>> does not make a difference, it just adds the relationships to a >>>>> global list >>>>> >>> of allowed relationships for the description... how would i ensure >>>>> that the >>>>> >>> traversal only goes from preferred store, to ordered, to the >>>>> product? >>>>> >>> >>>>> >>> -- >>>>> >>> You received this message because you are subscribed to the Google >>>>> Groups >>>>> >>> "Neo4j" group. >>>>> >>> To unsubscribe from this group and stop receiving emails from it, >>>>> send an >>>>> >>> email to [email protected]. >>>>> >>> >>>>> >>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >> >>>>> >> >>>>> > -- >>>>> > You received this message because you are subscribed to the Google >>>>> Groups >>>>> > "Neo4j" group. >>>>> > To unsubscribe from this group and stop receiving emails from it, >>>>> send an >>>>> > email to [email protected]. >>>>> > For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>> -- >>>> You received this message because you are subscribed to a topic in the >>>> Google Groups "Neo4j" group. >>>> To unsubscribe from this topic, visit https://groups.google.com/d/ >>>> topic/neo4j/9JfW_RBLJF4/unsubscribe. >>>> To unsubscribe from this group and all its topics, send an email to >>>> [email protected]. >>>> >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>> >>> >> -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
