简体   繁体   English

Cypher中路径的零个或多个

[英]Zero or more length of path in Cypher

For example I have a path: 例如,我有一条路径:

1-[:A]->2-[:B]->3

And we can use the * operator to define if a particular edge can be repeated. 我们可以使用*运算符定义是否可以重复特定边。 I would like to use the * operator on the entire path, or both edges combined. 我想在整个路径上使用*运算符,或在两个边上结合使用。 I would like to follow: (A AND B) zero or more times. 我想遵循:(A和B)零次或多次。

Example: 例:

1-[:A]->2-[:B]->3-[:A]->4-[:B]->5...

I am not sure how to apply the * operator for the entire path in Cypher. 我不确定如何在Cypher的整个路径中应用*运算符。 My intent is to express a pattern that allows a specific path to be repeated 0 or more times. 我的意图是表达一种模式,该模式允许将特定路径重复0次或多次。

This is something variable-length patterns cannot do in Cypher. 这是可变长度模式在Cypher中无法做到的。 However, because of this, we added repeating sequences functionality to path expander procs in APOC Procedures . 但是,由于这个原因,我们在APOC Procedures中路径扩展器proc添加了重复序列功能。

As an example: 举个例子:

MATCH (n)
WHERE id(n) = 123
CALL apoc.path.expandConfig(n, {relationshipFilter:'A>, B>'}) YIELD path
RETURN path

This expands from a start node ( n ) expanding out only a repeating sequence of outgoing :A and :B relationships. 这从起始节点( n )扩展,仅扩展了传出:A和:B关系的重复序列。 No minLevel or maxLevel properties were provided, so this has a minimum of 0 length and no bounds on max length. 没有提供minLevel或maxLevel属性,因此长度最小为0,最大长度没有界限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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