2
votes

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 - enter image description here

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?

1
It is Cypher with a Y :)Michael Hunger
My apologies! One of the downfalls of being a beginner, yet!Manish Giri

1 Answers

4
votes

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)