Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between -, -> and --> when querying using Cypher (Neo4j)

Tags:

neo4j

cypher

I have seen different versions of "linking" in Cypher for example:

  1. match (n)-[r]-() delete, n, r
  2. merge (n) -[:TO {dist:line.distance}] -> (m)
  3. match (n:MyNode)-[r:TO]->(m) where not ((m)-->())

where these links can be assigned using 1) "-", 2) "->" 3) "-->", I was wondering what the difference between these three types are. In these different contexts, I see that they are used differently but was wondering if there was a general rule for understanding this.

like image 323
youngrao Avatar asked Jan 31 '23 00:01

youngrao


1 Answers

  1. (n)-[r]-() means that you do not care about the directionality of the relationship r.

  2. (n)-[r]->(m) means that the relationship r must be directed from n to m.

  3. (n)-->(m) means that you do not want to qualify the relationship pattern (e.g., specify a type) nor get any data from the relationship via an identifier (e.g., r).

You can read the documentation to get more informtion.

like image 101
cybersam Avatar answered Feb 08 '23 14:02

cybersam