密码零长度路径默认匹配规则

cypher zero length path default matching rule

默认情况下,这些密码符号 (a)-[*]->(b)(a)-[*..5]->(b) 是否包含此模式 (a)-[*0]->(b)(意味着 a 和 b 是同一节点)?

我是否需要像 (a)-[*0..]->(b)(a)-[*0..5]->(b) 那样明确拼写出来?

这对于边缘/子路径的可选匹配特别方便。
请参阅 MATCH and Patterns 上的参考文档,以防我在那里遗漏了它。

引用文档:

Nodes that are a variable number of relationship→node hops away can be found using the following syntax: -[:TYPE*minHops..maxHops]->. minHops and maxHops are optional and default to 1 and infinity respectively. When no bounds are given the dots may be omitted.

因此,要匹配长度为 0 的路径,您必须明确使用 0 作为 minHops:

(a)-[*0..5]->(b)

这将匹配从 0 到 5 跳的路径,因此 ab 可能指的是同一个节点。

相比之下,(a)-[*..5]-(b) 将匹配 1 到 5 跳。