Hi Joshi,

the problem may be that your traversal description will traverse from
actor to director (in both directions) and also from director to
actors (also in both directions).

Your "manual" traverser traverses actors to directors in both
directions and then only incoming relationships from director to
actor. So there's a difference there.

In your case it may be better to do the manual thing, or instead have
two relationship types, actor_worked_with_director and
director_worked_with_actor so that you can specify a more granular
traversal description with:

actor_worked_with_director: BOTH
director_worked_with_actor: INCOMING

2010/12/7, Joshi Hemant - hjoshi <hemant.jo...@acxiom.com>:
> I have graph of 2 types of nodes : actors and directors. The graph is
> constructed such that an actor may have worked with multiple directors
> and the director may have worked with different actors. The objective is
> to find the list of actors (sorted by frequency) who have shared the
> most number of directors (for the given Actor1). The traversal
> description I wrote looks like :
> Actor1 --> Director1 <-- Actor2
> Actor1 --> Director2 <--Actor2
> Actor1 --> Director3 <-- Actor2
> Actor1 --> Director4 <-- Actor3
> ... and so on
>
> for(Node otherActorNode : Traversal.description().relationships(
> MyRelationshipTypes.WORKED_WITH,Direction.BOTH)
>       .breadthFirst().uniqueness(Uniqueness.NODE_PATH)
>       .prune( Traversal.pruneAfterDepth( 2 ) )
>       .traverse(givenActorNode).nodes()){
>       //Keep frequency updated for otherActorNode
> }
> // Display sorted list of otherActorNode that have worked with common
> director
>
> The problem is that I am getting higher (incorrect) scores of the shared
> number of unique directors for a given 2 actors. I used node_path
> uniqueness to make sure that we do not traverse same path twice.
> Instead of one traverser call if I split it into 2 calls:
> 1. Get all directors the givenActorNode has worked_with
> 2. For all director nodes, get incoming worked_with relationship and
> count frequencies (except givenActorNode)
> I get the correct results:
>
> Am I missing in the single traversal description above?
> -Hemant
>
> ***************************************************************************
> 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
>


-- 
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

Reply via email to