我正在使用 NeoDash,我想生成一个图形报告,其中每个节点大小按邻居数量加权。
所以这个计数必须成为 NeoDash 正确分析的节点的属性。
现在,经过 4 个小时,我终于成功完成了以下查询,但我很确定应该有一种更优雅、更简洁的方法来完成同样的任务,对吧?
MATCH path=(n)-[r]->(c) //n is already from a subset, and here we exclude _events
WHERE NOT c:_event
WITH collect(distinct n) as listN, collect(distinct c) as listC
UNWIND listN as n
MATCH (n)-[r]->(c) WHERE c in listC
WITH listN, listC, n, count(c) as countC
SET n.counter=countC
WITH collect(n) as listN, listC
UNWIND listC as c
MATCH (n)-[r]->(c) WHERE n in listN
WITH c, count(n) as countN, listN
SET c.counter=countN
WITH collect(c) as listC, listN
MATCH (n)-[r]->(c)
WHERE n in listN
and c in listC
RETURN n,r,c
或者有 apoc 的快捷方式吗?