[英]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. 我正在学习Neo4J,在阅读O'Reilly的《图形数据库》一书时,我遇到了一种图形模式,该图形模式描述了三个表示为节点的朋友,它们之间的关系方向表示谁是谁的朋友。
From the diagram, I can understand that - b knows a, c knows a and c knows b
从图中可以看出
b knows a, c knows a and c knows b
But the Cypher query pattern isn't clear to me - 但是Cypher查询模式对我来说并不明确-
(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 <- -).
使用ASCII字符表示节点和关系,我们绘制感兴趣的数据。我们使用圆括号来绘制节点,并使用破折号和大于和小于号对来绘制关系(-->和<-- )。 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
. 如果是这种情况,
(a)-[:KNOWS]->(b)-[:KNOWS]->(c)
表示a KNOWS b
和b KNOWS c
,以及(a)-[:KNOWS]->(c)
表示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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.