Hi,

I would do this using Gremlin as such:

        g.v(1).out('read').in('wrote').uniqueObject.out('pet').name

If you are vertex 1 (g.v(1)), 
        then you will go to the books you read, 
        then to the authors of those books,
        then because you might have read two Stephen King books, you will 
remove duplicates,
        then to their pets,
        and then to the names of those pets.

This assumes a graph of the form:

        person ---read--> book <---wrote--- person ---pet---> 
animal[string:name]

Take care,
Marko.

http://markorodriguez.com

On Sep 9, 2011, at 8:48 AM, Linan Wang wrote:

> Hi,
> 
> say people read books, books are written by authors, authors has dogs,
> then how to reach the dogs of authors of books i've read? when i'm
> also a writer, also have dogs, the TraversalDescription seems
> inefficient since it'll also traverse my own books and dogs first,
> before my customised StopEvaluator stops the expansion process.
> 
> my feeling is RelationshipExpander is the way to go but stucked at the
> problem to get the depth info. my goal is to have the designated
> RelationshipExpander to tell traverser that at depth 1 only looking
> for OUTGOING read relationship, depth 2 for INCOMING wrote
> relationship and depth 3 for OUTGOING has relationship. any comment is
> appreciated! thanks.
> 
> -- 
> Best regards
> 
> Linan Wang
> _______________________________________________
> 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

Reply via email to