1

Overlapping bidirectional relationship

Is it possible to show only one direction relationship from a bidirectional relationship?

(n)-[:EMAIL_LINK]->(m)

(n)<-[:EMAIL_LINK]-(m)

Daryl
  • 35
  • 3
  • 2
    No in the browser you can't. However if you upgrade to 2.2M04, the browser shows them in a better way with curved edges. – Christophe Willemsen Feb 20 '15 at 06:50
  • Is it possible to eliminate the redundant relationship between two nodes in cyper result set? I mean just hide or not to show in the result set. `14 --> 41 , 41 --> 14 , 62 --> 41 , 62 --> 14` As you can see the node(14) is directly related to node(41), same with node(41) which is directly related node(14). All I want to show is the unique node relationship in any directions. `14 --> 41 , 62 --> 41 , 62 --> 14` or `41 --> 14 , 62 --> 41 , 62 --> 14` – Daryl Feb 20 '15 at 07:53

1 Answers1

3

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, i.e. (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.

Stefan Armbruster
  • 39,465
  • 6
  • 87
  • 97