Reputation: 166
For the below graph...
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.
Upvotes: 1
Views: 1234
Reputation: 2583
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
Upvotes: 1