Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-01-2021 01:33 AM
Given a Graph of children which each have a link to their parent, how can I perform an aggregation of these sub edges on the child level to a single edge at the top level which is simply the sum of the sub edges?
Solved! Go to Solution.
05-02-2021 01:00 AM
Assuming you have relationship types HAS and LINKS_TO and no grandchildren, the following Cypher query should work:
MATCH (p1)-[h1:HAS]->(c1)-[r:LINKS_TO]->(c2)<-[h2:HAS]-(p2)
WITH p1, p2, count(r) as linkCount
MERGE (p1)-[:DIRECT_LINK {strength: linkCount}]->(p2)
Before:
05-02-2021 01:00 AM
Assuming you have relationship types HAS and LINKS_TO and no grandchildren, the following Cypher query should work:
MATCH (p1)-[h1:HAS]->(c1)-[r:LINKS_TO]->(c2)<-[h2:HAS]-(p2)
WITH p1, p2, count(r) as linkCount
MERGE (p1)-[:DIRECT_LINK {strength: linkCount}]->(p2)
Before:
All the sessions of the conference are now available online