Is it possible to show only one direction relationship from a bidirectional relationship?
(n)-[:EMAIL_LINK]->(m)
(n)<-[:EMAIL_LINK]-(m)
If the relationship type in question does not have directional semantics, it's best practice to have them only one time in the graph and omit the direction while querying, ie (a)-[:EMAIL_LINK]-(b)
instead of (a)-[:EMAIL_LINK]->(b)
.
To get rid of duplicated relationships in different directions, use:
MATCH (a)-[r1:EMAIL_LINK]->(b)<-[r2:EMAIL_LINK]-(a)
WHERE ID(a)<ID(b)
DELETE r2
if your graph is large you need to take care of having reasonable transaction sizes by adding a LIMIT
and running the query multiple times until all have been processed.
NB: the WHERE ID(a)<ID(b)
is necessary. Otherwise a
and b
might change roles during in a later iteration. Consequently r1
and r2
would change roles as well and both get deleted.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.