How to return all nodes and relationships from a set of nodes?

(Sbaskin) #1

Given a set of nodes, I want to return all relationships within that set without leaving out any nodes that do not have a relationship in that set.

I have no problem getting all nodes that have a relationship within that set, however, I cannot also include nodes that do not have a relationship within the set.

(Ameyasoft) #2


Use OPTIONAL MATCH to get the other nodes. Here is a sample query:

MATCH (a:Actor)-->(m:Movie)-->(d:Director)-->(t:Theater)
RETURN a, m, d, t, b;



(Andrew Bowman) #3

You can use apoc.algo.cover(nodeList) YIELD rel to get all the relationships between a list of nodes.