Pregunta

I am working on building a flow model within Neo4j and looking to initially weight all edges as a proportion of the total relationships e.g.

Node A -r1-> Node B, Node A -r2-> Node C, Node A -r3-> Node D

Using the above relationships the weight(ratio) of r1,r2 and r3 would be 1/3. I am able to work out the total inbound edges:

MATCH (n)<-[r:RTYPE]-m-[r2:RTYPE]->o return n,r,count(r2)

However when I try:

MATCH (n)<-[r:RTYPE]-m-[r2:RTYPE]->o SET r.Ration = 1/count(r2)

I get a Neo.ClientError.Statement.InvalidSyntax.

Any / all help appreciated.

¿Fue útil?

Solución

Please try

MATCH (n)<-[r:RTYPE]-m-[r2:RTYPE]->o
WITH r, count(r2) as r2count
SET r.Ration = 1/r2count

(move the aggregate function into WITH)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top