1
votes

For the below graph...

enter image description here

I am struggling to compose a Cypher query that will return me the neighbourhood graph (relationships) of node 1. The neighbourhood graph of 1 includes the nodes connected by the relations I have marked with dotted lines. These are the nodes pointing to 1, pointed at by 1 and all other inter-connections between these nodes.

This below query

START a=node(15151) MATCH (a)-[r]-(b) RETURN r

gives me back the relations between 1 and 2,3,4,5 but I also need the relations between 2-4 and 3-5 to be returned in the same query.

1

1 Answers

1
votes

Try this

  START a= node(15151) MATCH (a)-[r1]-(b) WITH a,b,collect(b) as bAll,r1 
   MATCH (b)-[r2]->(c) WHERE (c IN bAll) and a <> c return r1,r2