匹配单人关系 [英] Match single relationship

查看:86
本文介绍了匹配单人关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是如何有效查找多个关系大小的后续问题

假定使用电影示例图

运行以下查询时

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆