Reputation: 1005
How do I create a transitive relationship which maps back to the same initial label. I am trying to map data from tables that go something like this :-
A -> B -> C -> A
B has the index column from A, and C has the index column from B and A (multiple). It is a kind of transitive relationship, wherein I need to map a specific row in A back to different rows in A. How do I go about doing this?
This is to be done on the labels for the whole data set, and not to be filtered for any given id. The labels are already existing in the db.
Upvotes: 0
Views: 94
Reputation: 9284
If you already have relations from A->B and B->C, then it can be simply achieved as follows, assuming the relationship type to be X
:
MATCH (a:A)-[:X]->(:B)-[:X]->(c:C)
MERGE (c)-[:X]->(a)
This will create a relationship between every C
and A
, when they are linked via B
Upvotes: 1