Probably because the property name "fweight" in your "Return" does not match the name "weight", which is actually used for the relationship "r" or "s". It should work if you change it to
RETURN sum(r.weight), sum(s.weight)
But the result is the sum over all tuples (r, s), which will include many duplicates of r and duplicates of s.
To get the exact amount, you can get a collection of different r and s, and then summarize over such collections,
RETURN reduce(sumr = 0, x in collect(distinct r)|sumr + x.weight) as sumr, reduce(sums = 0, x in collect(distinct s)|sums + x.weight) as sums
The console that displays a direct sum query on the properties "r" and "s" is here, http://console.neo4j.org/?id=cqs2h7
The console that displays the collection request is located here http://console.neo4j.org/?id=9st2mq
You would notice that although both of them return amounts, the results of the first query with βsum RETURN (r.weight), sum (s.weight)β include duplicate relations βrβ and βsβ, while the second query with collections removes duplicates and returns the desired amount.
Lisa li
source share