[英]Neo4j - Cypher query for finding neighbourhood graph
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. 我正在努力编写一个Cypher查询,该查询将向我返回节点1的邻域图(关系)。1的邻域图包括通过用虚线标记的关系所连接的节点。 These are the nodes pointing to 1, pointed at by 1 and all other inter-connections between these nodes. 这些是指向1的节点(由1指向)以及这些节点之间的所有其他互连。
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和2,3,4,5之间的关系,但我还需要在同一查询中返回2-4和3-5之间的关系。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.