我有一个图表,其中一些节点之间存在许多关系,这使得浏览这些图表变得困难。是否有可能用单个"聚合"替换这种多重关系。一,可能是另一种类型?
理想情况下,我想加入节点疼痛之间存在超过10种关系的那些关系 - 但任何事情都会有所帮助。
答案 0 :(得分:1)
我认为你可以这样做:
// Match the pattern
MATCH (a:Node)-[t:REL_TYPE]->(b:Node)
// pass to the next context nodes a, b, list of t
// where number of relations between a and b is greater than 10
WITH a, b, collect(t) AS ts, count(t) AS count
WHERE count > 10
// create new relation between a and b nodes
CREATE (a)-[:OTHER_REL_TYPE]->(b)
// pass list of old relations to the next context
WITH ts
// unwind & delete old relations
UNWIND (ts) AS t
DELETE t
RETURN *