Return 到具有多于 N 个关系的节点的路径

Return paths to nodes with more than N relationships

我的数据库中有 User 和 Repository 节点,它们之间存在关系。

我想取回用户和“超过 100 个用户指向它们的存储库”(它们之间的节点数量可变)之间的路径。

此查询有效,但仅 return 存储库:

match p=(u:User)-[*..2]->(r:Repository)
with *, relationships(p) as rel
with r, count(rel) as rel_count
where rel_count > 100
return r

我还想要用户和路径 returned,所以我尝试了这个:

match p=(u:User)-[*..2]->(r:Repository)
with *, relationships(p) as rel
with p,r, count(rel) as rel_count
where rel_count > 100
return p

其中 returns 0 条记录(相对于上述查询的 ~200),原因我不确定。

如何 return 所有 路径 到具有超过 N 个关系的节点?[​​=28=]

我会尝试这样的事情

MATCH p=(u:User)-[*..2]->(r:Repository)
WITH r,
     COLLECT(p) AS ps,
     COUNT(DISTINCT u) AS userCount
WHERE userCount > 100
UNWIND ps AS p
RETURN p