I apologies if my question is trivial i am a NOOB at neo4j.
I am trying to write a cypher query that will find all the purple nodes desc order from the value of [sum ( mass_of * contains ) for all paths going from purple to red ]
example: In picture it would be [( mass_of * contains )] for all red paths then sum all the red paths.
I started with this query but i m not sure where to go from here.
MATCH p0=(p:Purple)-[m:mass_of]->(g:Green)-[c:contains]->(r:red {name: "something"})
WITH m, c.amount * m.amount as total_per_path
WITH total_per_path, reduce( total=0, node IN collect(m)| total + total_per_path) AS total_something
RETURN total_something as TOTAL, total_per_path as PER_TOTAL_PATH
...
thanks for any help.
This should do it
MATCH (p:Purple)-[m:mass_of]->(g:Green)-[c:contains]->(r:red {name: "something"})
RETURN p, SUM(c.amount * m.amount) AS total
ORDER BY total DESC
You can also collect the m,g or c in return if you need that nodes/relationships.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With