简体   繁体   中英

Neo4J Cypher Pattern syntax

I am learning Neo4J, and while reading the book "Graph Databases" by O'Reilly, I came across a graph pattern which describes three friends, represented as nodes and the relationship direction between them signifying who is whose friend.

Here's the diagram - 在此处输入图片说明

From the diagram, I can understand that - b knows a, c knows a and c knows b

But the Cypher query pattern isn't clear to me -

(a)-[:KNOWS]->(b)-[:KNOWS]->(c), (a)-[:KNOWS]->(c)

On the next section, where they describe the syntax, they mention -

Using ASCII characters to represent nodes and relationships, we draw the data we're interested in. We use parantheses to draw nodes, and pairs of dashes and greater-than and less-than sign to draw relationships(- -> and <- -). The < and > signs indicate relationship direction.

If this is the case, (a)-[:KNOWS]->(b)-[:KNOWS]->(c) signifies that a KNOWS b and b KNOWS c , and (a)-[:KNOWS]->(c) signifies that a KNOWS c . Isn't this the opposite of what the arrows in the diagram depict?

That seems to be a mistake in the book. The shown diagram is expressed by

(a)<-[:KNOWS]-(b)<-[:KNOWS]-(c), (c)-[:KNOWS]->(a)

or

(a)<-[:KNOWS]-(b)<-[:KNOWS]-(c)-[:KNOWS]->(a)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM