Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-07-2020 08:41 AM
Hello,
My problem is the following.
I have 4 nodes A B C D.
I have relationships with percentage.
I consider that two nodes are in the same cluster if it exists a relationship with a percentage above 50%.
“A - > B [100]“ means A owns B with 100% share, so A and B must be in the same cluster.
My data are:
So A, B and C are in the same cluster.
But D must be in the same cluster because the relationships between the cluster and D are above 50 (40+30).
Have you an idea to create automatically the correct cluster?
Best regards,
Alexandre
04-07-2020 07:58 PM
With my little understanding of your scenario, here is my solution.
I created your scenario:
merge (a:Name {name: "A", val: toInteger("100")})
merge (b:Name {name: "B", val: toInteger("100")})
merge (c:Name {name: "C", val: toInteger("100")})
merge (d:Name {name: "D", val: toInteger("30")})
merge (d1:Name {name: "D", val: toInteger("40")})
merge (a)-[:REL]->(b)
merge (a)-[:REL]->(c)
merge (b)-[:REL]->(d1)
merge (c)-[:REL]->(d)
return a, b, c, d, d1
Result:
Run this query:
match (a:Name)
with a.name as name, sum(a.val) as sum1
with collect ({nme: name, sumval: sum1}) as reslt
unwind reslt as row
with row where row.sumval >= 80
return row.nme as name, row.sumval as Val
Result:
04-07-2020 11:33 PM
Thanks for you help.
But the value of percent is a property of relationship, not of a node.
Moreover, the goal is to build an algorithm (or to reuse one) in order to build a new relationship between the cluster and the node D since the sum of percents is above 50.0. I think that the final relationship created must have "A" as parent; because A is the first common parent of B and C.
Is it more clear ?
All the sessions of the conference are now available online