I am trying to use Neo4j to write a query that aggregates values ββalong a specific subgraph.
We have two stores Store1 and Store2 one with supplier S1 other with supplier S2 . We are moving 100 units from Store1 to Store3 and 200 units from Store2 to Store3 .
Then we move 100 units from Store3 to Store4 . So now Store4 has 100 units, and about 33 - from the supplier S1 and 66 from the supplier S2 .

I need a query to effectively return this information, for example.
S1, 33
S2, 66
I have a recursive query to aggregate all movements along each path
MATCH p=(store1:Store)-[m:MOVE_TO*]->(store2:Store { Name: 'Store4'}) RETURN store1.Supplier, reduce(amount = 0, n IN relationships(p) | amount + n.Quantity) AS reduction
Return:
| shop. Supplier | decline |
| -------------------- | ------------- |
| S1 | 200 |
| S2 | 300 |
| null | 100 |
Desired:
| shop. Supplier | decline |
| --------------------- | ------------- |
| S1 | 33.33 | | S2 | 66.67 |
source share