Neo4j - calculate & set node property based on relation property

孤者浪人 提交于 2019-12-25 09:06:57

问题


I want to know, if it's possible to calculate & set (update) a node property based relation properties (incoming&outgoing)? In my example, I would like to calculate an user personal "strength factor" (Kind of average) based on his relationships duration (int) divided by the count (int).

Thanks for your help in advance,

Cheers


回答1:


Yes, it's possible. The only trick is that you have to use WITH to first perform the aggregation (for calculating the average):

MATCH (n)-[r:RELTYPE]->()
WITH n, avg(r.duration) AS strength
SET n.strength = strength


来源:https://stackoverflow.com/questions/42649043/neo4j-calculate-set-node-property-based-on-relation-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!