如何在neo4j中使用cypher查找彼此之间具有多个关系的节点?

如何在neo4j中使用cypher查找彼此之间具有多个关系的节点?,neo4j,cypher,Neo4j,Cypher,识别具有一定数量的传入或传出关系的节点很容易,但我想识别连接冗余,因此我想获得一组相互之间具有多个关系的所有节点 很遗憾,伪代码不会返回任何结果: MATCH (n1)-[r]-(n2) with distinct n1,r,n2, count(r) as sstcount where sstcount > 1 RETURN n1,r,n2 我想我找到了一个解决方案,查询需要正确链接。高度赞赏任何“更好的解决方案” MATCH (n1)-[r]-(n2) WITH distinct n1

识别具有一定数量的传入或传出关系的节点很容易,但我想识别连接冗余,因此我想获得一组相互之间具有多个关系的所有节点

很遗憾,伪代码不会返回任何结果:

MATCH (n1)-[r]-(n2)
with distinct n1,r,n2, count(r) as sstcount
where sstcount > 1
RETURN n1,r,n2

我想我找到了一个解决方案,查询需要正确链接。高度赞赏任何“更好的解决方案”

MATCH (n1)-[r]-(n2)
WITH distinct n1,n2, count(r) as sstcount
MATCH (n1)-[r]-(n2)
where sstcount>1
return n1,r,n2
试试这个:

MATCH (n1)-[r]-(n2)
WHERE id(n1) < id(n2) // so we avoid matching to the same nodes in swapped order
WITH n1,n2, count(r) as sstcount
WHERE sstcount > 1
RETURN n1, n2
匹配(n1)-[r]-(n2)
其中id(n1)1
返回n1,n2