0

I have a fairly simple graph, with the caveat that all edges are marked with 'to' and 'from' dates stored as timestamps.

I'm trying to write a traversal that will only follow edges that overlap with the first traversed edge's To and From dates.

Note that the To-date can be non-existent, indicating that the edge is still active.

I've tried various things, but the closest I've come so far is:

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'))

I'm pretty sure the problem is related to the store commands and subsequent usage, as the following query does not return anything either (It should return any inactive edges created after the first edge).

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'))
bech
  • 627
  • 5
  • 22
  • Additionally, I'm using CosmosDB so using a sack is not supported :/ – bech Feb 18 '21 at 08:34
  • 1
    It would be helpful if you could provide some `addV` and `addE` steps that build a sample graph and also provide the expected output from the query. – Kelvin Lawrence Feb 27 '21 at 19:38

0 Answers0