我有一段(损坏的)gremlin 代码来生成从给定顶点到具有参数的最短路径test_parameter
。如果在边上找不到该参数,则不应返回任何路径。
s.V(377524408).repeat(bothE().has('date', between(1554076800, 1556668800)).otherV()) /* date filter on edges */
.until(or(__.bothE().has('test_property', gt(0)),
loops().is(4))) /* broken logic! */
.path()
.local(unfold().filter(__.has('entity_id')).fold()) /* remove edges from output paths*/
断线的是.until(or(__.outE().has('test_property', gt(0)), loops().is(4)))
。
目前——而且它的原因是有道理的——它给出了距离起始顶点 4 跳的所有路径。
我正在尝试对其进行调整,以便如果遍历是 4 次迭代,并且如果找不到该属性test_property
,那么它不应该返回任何路径。如果test_property
找到,它应该只返回该顶点的路径。
我试图在times(4)
条件中加入约束并删除loops()
条件,但不知道如何同时拥有times(4)
this 和.has('test_property', gt(0))
约束。