匹配单人关系 [英] Match single relationship
问题描述
假定使用电影示例图
运行以下查询时
MATCH()-[:PRODUCED]-()RETURN count(*)
我们知道有15个已生产
关系。
从查询
Assuming working with the movie sample graph
When running the below query
MATCH ()-[:PRODUCED]-() RETURN count(*)
we know that there are 15 PRODUCED
relationships.
From the query
MATCH (n)-->(m)
WITH n,m, COUNT(*) as cnt
WHERE cnt=3 RETURN *
我们知道有2个已生产
将2个节点与其他关系连接起来的关系。
We know there are 2 PRODUCED
relationships that connect 2 nodes with additional relationships.
我们如何找到节点之间不同的关系(即除了 PRODUCED
关系)?
How can we find the relationships that are distinct relationships between nodes (i.e. there are no additional relationships except for the PRODUCED
relationship)?
推荐答案
我们的解决方案正在使用此查询
Our solution was using this query
MATCH p=(n)-[:PRODUCED]->(m)
WHERE size((n)--(m))=1
RETURN count(p)
其结果为9(总数为15,大小= 3为2,大小= 2是4)
which results with 9 (total is 15, with size=3 is 2, and size=2 is 4)
这篇关于匹配单人关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!