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.
collect
on the basis ofm
- that bit is confusing becausem
is a relationship, but then you're sayingnode in collect(m)
which doesn't really make sense, and then in the expression after it you're not usingnode
. So it seems liketotal_per_path
mostly has what you want....why not sum all of thetotal_per_path
variables? – FrobberOfBitstotal_per_path
but that sums all the oranges and all the red paths. I want to have the sum for all the red paths and the sum for all the orange paths. I was trying to collect bym
because it's represents a path ( but that does not seam quite right ) – user618589