天天看點

protege和neo4j聯系_Neo4j-計算和根據關系屬性設定節點屬性

protege和neo4j聯系_Neo4j-計算和根據關系屬性設定節點屬性

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

解決方案

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