neo4j - Aggregating relationship properties on a path -
i'm trying to sum of weights on each path match finds. query below:
start n=node(10200) match p=(n)-[r*1..5]->(m:facility) reduce(weights=0, rel in r : weights + rel.weight) weight_sum all(n in nodes(p) 1=length(filter(m in nodes(p) : m=n))) return p paths, length(p) pc, (weight_sum / (length(p) * (length(p) / 2))) sp;
every time run it, i'm getting...
unknown identifier `p`
if remove line (and weight_sum return value), query knows 'p' , executes fine. there problem query value of 'p' being lost? there better alternative sum of these relationship properties?
you can pipe "p" next part of query via with:
start n=node(10200) match p=(n)-[r*1..5]->(m:facility) reduce(weights=0, rel in r : weights + rel.weight) weight_sum, p all(n in nodes(p) 1=length(filter(m in nodes(p) : m=n))) return p paths, length(p) pc, (weight_sum / (length(p) * (length(p) / 2))) sp;
Comments
Post a Comment