2015-02-24 600 views

回答

1

是的,绝对的,这是可行的密码。这是一个例子。

// 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) 
+0

非常感谢您的回复。不幸的是,这个查询似乎返回了与*的任何*元素相邻的所有节点。我想要的是找到与C的* all *元素相邻的节点。 – cmc 2015-02-24 19:03:28

+0

您的回复帮助我理解数据的声明和流然而,再次感谢:) – cmc 2015-02-24 19:04:19

+0

这找到了C中的所有元素,然后找到与C的每个元素相邻的所有节点。它只查找出站相邻节点,但很容易更改通过消除关系中的箭头。是否要将所有与C集相邻的节点作为单个集合返回? – 2015-02-24 19:59:44