Neo4j - 寻找邻居图的Cypher查询 [英] Neo4j - Cypher query for finding neighbourhood graph

查看:945
本文介绍了Neo4j - 寻找邻居图的Cypher查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的图表...

我正努力编写一个Cypher查询,它将返回节点1的邻域图(关系)。邻域图1包含节点由我用虚线标出的关系连接起来。这些节点指向1,指向1以及这些节点之间的所有其他内部连接。

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.

以下查询

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

给我回1和2,3,4,5之间的关系,但我也需要在相同的查询中返回2-4和3-5之间的关系。

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.

推荐答案

试试这个

  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

这篇关于Neo4j - 寻找邻居图的Cypher查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆