I have following analysis data
Problem statement: Find out a session (From Neptune session) that contains least inbetween vertex. As you can see expected output for following example data is [11, 12, 1, 2, 3] as it contains continued 1,2,3 connected vertices and none inbetween. The target is to pick the array which contains lesser inbetween vertex 1 , 2 and 3.
{
inputGiven: [1, 2, 3],
neptuneSessions: [[1, 2, 5, 6, 3], [11, 12, 1, 2, 3], [2, 4, 5]],
expectedOutput: [11, 12, 1, 2, 3],
}
The solution I came up with is to query out all the related traversal which contain 1, 2 or 3 vertices and then apply logic to it. But I am looking out of solution through gremlin query
public async addNode(node: NeptuneNode): Promise<void> {
const nodeValue = await this.traversal
.V(A)
.fold()
.coalesce(this.__.unfold(), this.__.addV('action').property(id, A))
.property('EVENT_ID', EVENT_ID)
.property('EA', EA)
.property('A', A)
.next()
console.log('--node--> ', nodeValue)
}
public async addEdge(event: NeptuneEdge): Promise<any> {
const edge = await this.traversal.addE('next')
.from_(this.traversal.V(event.PH.toString()))
.to(this.traversal.V(event.A.toString()))
.property('ID', event.ID)
.property('SESSION_ID', event.SESSION_ID)
.property('DH', event.DH)
.property('A', event.A)
.property('PH', event.PH)
.next()
console.log('--edge--> ', edge)
}
sample graph