I’m trying to write a password query, which will start from [ Find the desc order of all purple nodes in the value of sum(mass_of * contains), all paths change from purple to red]
Example:
In the picture, for all red paths, it will be [ (mass_of * contains)], and then sum all the red paths.
I started with this query, but I don’t know where to start.
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
< p>…
Thank you for your help.
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
If you need nodes/relationships, you can also Collect m, g or c in return.
If my question is simple, I am sorry, I am NOOB of neo4j.
Example:
In the picture, for all red paths, it will be [(mass_of * contains)], and then find all red paths And.
I started with this query, but I don’t know where to start.
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
…
Thank you 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
If you need nodes/relationships, you can also collect m, g or c in return.