我正在尝试解决此问题,因为自过去三天以来。但无法找到合适的解决方案。我以前问了这个问题。比我把查询减少到一个数字,看看问题是什么。问题最终我收到了7个节点,双向关系。这意味着7个节点共有17个关系。在图形视图中,它是14,但在计数表中,关系计数为28.这意味着它在计数中加倍。为了更清楚,我附上图像和查询。
START n= node(2679)
MATCH p=(n)-[:CALLS]-(a),(n)-[:CALLS]-(b),(a)-[:CALLS]-(n)-[:CALLS]-(b)
WITH a,b,n,p
OPTIONAL MATCH q=(a)-[:CALLS]-(b),(b)-[:CALLS]-(a) with a,b,n,p,q
RETURN q;
对于使用查询时使用distinct子句计算关系时的相同数据
START n= NODE(2679)
MATCH p=(n)-[:CALLS]-(a),(n)-[:CALLS]-(b),(a)-[:CALLS]-(n)-[:CALLS]-(b)
WITH a,b,n,p
OPTIONAL MATCH q=(a)-[:CALLS]-(b),(b)-[:CALLS]-(a) WITH a,b,n,p,q
RETURN COUNT (DISTINCT p ) as ALL_PATHS,
COUNT (DISTINCT q) AS Backyard_Paths
ORDER BY Given_Numbers ASC;
我无法检查每个值,因为我的数据是数百万。提前致谢
答案 0 :(得分:0)
这样的事情会让你得到你想要的东西吗?
// find yourself and all of the friends that you call
match (me:Node {name:'center'})-[:CALLS]->(friend)
// put all of your friends in a collection
with me, collect(friend) as friends
// then with the collection of your friends
// find out which of your friends they call
unwind friends as one_friend
match one_friend-[r:CALLS]->(another_friend)
// only match other friends that are in your friends list
where another_friend in friends
and not one_friend = another_friend
return count(r)