Count relationships

Hi Guys,

i have this query that outputs what is in the attached picture. I will connect the two "Generalization" nodes (green ones) but i want to add a "strenght" property to the new relationship with the number of connections between the "Perception_Group" nodes (yellow ones). So in this case i would have strenght=4. How can i count the relationships between the yellow nodes?

MATCH (g1:Generalization)-[i1:INSTANCEOF]-(pg1:Perception_Group)-[s:SEQUENCE]-(pg2:Perception_Group)-[i2:INSTANCEOF]-(g2:Generalization)
WHERE g1 <> g2
RETURN g1,g2,i1,i2,pg1,s

Guys.

It was easier than i thought, so before anyone spends time with this question here is the cypher i got.


MATCH (g1:Generalization)-[i1:INSTANCEOF]-(pg1:Perception_Group)-[s:SEQUENCE]-(pg2:Perception_Group)-[i2:INSTANCEOF]-(g2:Generalization)
WHERE g1 <> g2
WITH count(distinct s) as strength, g1,g2
MERGE (g1)-[gs:GENERALIZATION_SEQUENCE {subType:'UE7',strength:strength}]-(g2)