m with r1.Frequency as Fre-6ren">
gpt4 book ai didi

neo4j - Cypher Query - 返回每个匹配关系的权重和总权重

转载 作者:行者123 更新时间:2023-12-01 04:36:55 30 4
gpt4 key购买 nike

我试图在下面的例子中找到百分比

START n=node:name_idx(NAME="ABC")
match p = n-[r1:LIKES]->m
with r1.Frequency as Frequency, Sum(r1.Frequency) as Sum
return Frequency, Sum

我希望得到这样的东西

Frequency        Sum
12 19
6 19
1 19

等等。

我得到的是 Frequency 和 Sum 列中的相同值

 Frequency        Sum
12 12
6 6
1 1

有什么关于如何获得正确分配的建议吗?我的最终目标是通过除以到达返回行的频率/总和来找出百分比。谢谢

最佳答案

这个怎么样(我偷了 Luanne 的控制台图):

http://console.neo4j.org/r/3axtkq

START n=node:node_auto_index(name="a") 
MATCH n-[r1:LIKES]->m
WITH sum(r1.frequency) AS total, n // we want the total... of all frequencies for n
MATCH n-[r1:LIKES]->m // we need to get the likes again, because those can't be passed in with and get the total of all at the same time
RETURN r1.frequency, total, r1.frequency/(total*1.0) // it does integer math unless you force one to be a float

关于neo4j - Cypher Query - 返回每个匹配关系的权重和总权重,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17938121/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com