0
votes

Imagine a node has two types of relationships to another node and only one type to the third node. For instance, in the manual (http://docs.neo4j.org/chunked/milestone/query-match.html#match-match-by-multiple-relationship-types) let's say Node7 also has an additional relationship with Node4 [DIRECTED] - so Douglas at the same time acted in and directed "the american president".

How to find (in cypher) all the nodes related to node7 exclusively on the type of relationship ACTED and not to show such ACTED-related nodes that also contain additional relationships?

1
So are you asking how to not show duplicated relationships?Nicholas

1 Answers

1
votes

How's this one?

start n=node(3084)
match n-[r]-m                     // might want to have direction?
with collect(r) as collr, m       // collect the relationships
where length(collr) = 1           // we only want nodes with 1 relationship
  and type(head(collr)) = "ACTED" // and the one relationship needs to be ACTED (I think it's actually ACTS_IN in the example dataset)
return m;