条件返回关系连线最多的节点
发布于 5 年前 作者 jasmine 2640 次浏览 来自 问答

目的:想要查询同时关联到 LabelA[‘s1’,‘s2’,‘s3’,‘s4’,‘s5’] 这5个节点的里连线最多的 LabelB 节点

with ['s1','s2','s3','s4','s5'] as lists
match p=(a:LabelA)<-[:REL]-(b:LabelB) where a.name in lists
return b,count(*)

查询结果示例如下:

b count(*)
B1 4
B2 4
B3 3
B4 2

想要做到同时返回count(*)结果最大的节点集合 【nodes: collect(B1,B2), maxCount:4】 这两个信息,要用什么方法才能做到呢? 还是必须先返回到代码里,用代码去做筛除 请各位大神指导一下,非常感谢

2 回复

没怎么看明白。你期待返回的结果是怎样的?

@graphway 期待的返回是 【nodes: collect(B1,B2), maxCount:4】这种形式,拿到 关联LabelA {s1~s5} 节点最多的 节点集合

回到顶部