Skip to content

Instantly share code, notes, and snippets.

Created July 12, 2015 20:16
Show Gist options
  • Save anonymous/14a04fa4a27d2167df39 to your computer and use it in GitHub Desktop.
Save anonymous/14a04fa4a27d2167df39 to your computer and use it in GitHub Desktop.
// Index lookup for the node representing the doctor is omitted for brevity
Iterable<Relationship> relationships = doctor.getRelationships( Direction.INCOMING, COMPANION_OF );
for ( Relationship rel : relationships )
{
Node companionNode = rel.getStartNode();
if ( companionNode.hasRelationship( Direction.OUTGOING, IS_A ) )
{
Relationship singleRelationship = companionNode.getSingleRelationship( IS_A, Direction.OUTGOING );
Node endNode = singleRelationship.getEndNode();
if ( endNode.equals( human ) )
{
// Found one!
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment