neo4j/cypher:查找某个集合中所有节点相邻的所有节点
问题描述:
给定一个节点s,它与一个标签的> 1个节点集合C相邻。我想找到这也是相邻的每个元素在C.neo4j/cypher:查找某个集合中所有节点相邻的所有节点
更普遍的所有节点:
- 一个人如何在暗号定义套或组?
- 如何找到一个集合中所有节点相邻的节点?
这是甚至可以在cypher?
答
是的,绝对的,这是可行的密码。这是一个例子。
// start with finding the start node 's' and the adjacent nodes
match (s:Node {name: 's'})-[:ADJ]->(C:Node)
// match only the adjacent nodes that have 'set C'
where C.set = 'C'
// pass C onto the remainder of the query
with s,C
// match the nodes that are adjacent to the nodes in 'set C'
match C-[:ADJ]->(adjacent)
// return all of the nodes in set C and a collection of the nodes
// adjacent to the set C nodes
return s.name, C.name, collect(adjacent.name)
非常感谢您的回复。不幸的是,这个查询似乎返回了与*的任何*元素相邻的所有节点。我想要的是找到与C的* all *元素相邻的节点。 – cmc 2015-02-24 19:03:28
您的回复帮助我理解数据的声明和流然而,再次感谢:) – cmc 2015-02-24 19:04:19
这找到了C中的所有元素,然后找到与C的每个元素相邻的所有节点。它只查找出站相邻节点,但很容易更改通过消除关系中的箭头。是否要将所有与C集相邻的节点作为单个集合返回? – 2015-02-24 19:59:44