Reputation: 178
I have a dataset where the following query returns the whole topology.
MATCH (na:node)-[ra:composition]-(ia:interface)-[rb:compound]-(ib:interface)-[rc:composition]-(nb:node)
RETURN na,ia,ib,nb
LIMIT 1000
I would like to merge ia and ib into only one relationship so that I will only get nodes connected to each other and not their intermediary interfaces.
Like this:
(na:node)-[r:CONNECTED_TO]-(nb:node)
Anyone know how?
Upvotes: 3
Views: 577
Reputation: 547
I'm not completely sure if I correctly understand what you want to do, but shooting from the hip:
MATCH (na:node)-[ra:composition]-(ia:interface)-[rb:compound]-(ib:interface)-[rc:composition]-(nb:node)
WITH na,nb
LIMIT 1000
MERGE (na)-[:CONNECTED_TO]-(nb)
RETURN count(*)
Run this query until count equals 0
Upvotes: 1