微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Gremlin 遍历参考先前的边

如何解决Gremlin 遍历参考先前的边

我有一个相当简单的图表,但需要注意的是,所有边都标有作为时间戳存储的“to”和“from”日期。

我正在尝试编写一个遍历,该遍历只会遵循与第一个遍历边的 To 和 From 日期重叠的边。

请注意,To-date 可以不存在,表示边缘仍然处于活动状态。

我尝试了各种方法,但迄今为止最接近的是:

g.V('1').outE().as('firstEdge')
.sideEffect(values('To').store('eto'))
.sideEffect(values('From').store('eFrom'))
.outV()
.repeat(outE().where(
    lte('firstEdge')).by('From') // The edge has a from-date less than firstEdge's from-date.
    .and(
        or(
            hasNot('To'),// The edge is still active,OR
            has('To',gte('eFrom')) // the edge has a to date after the firstEdge's from-date.
          )
    )
    .and(
        or(
            select('firstEdge').hasNot('To'),// The first edge does not have a to-date,OR
            has('From',lte('eto')) // The edge has a from date that is less than the first edge's to-date.
        )
    )
    .inV()
)
.emit()
.times(2) // Limit to two edges away.
.where(hasLabel('Person'))

我很确定问题与存储命令和后续使用有关,因为以下查询也不返回任何内容(它应该返回在第一个边之后创建的任何非活动边)。

g.V('1').outE('is_board')
    .sideEffect(values('From').store('eFrom'))
    .outV()
    .repeat(outE().has('To',gte('eFrom')).inV())
    .emit()
    .times(2)
    .where(hasLabel('Person'))

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。