0

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

Sample graph

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
Anish Giri
  • 66
  • 9
  • It will help people provide tested answers if you can add to your question some `addV` and `addE` steps that build a sample graph. The answer to this question shows a small sample graph being created: https://stackoverflow.com/questions/68930863/how-to-choose-right-nodes-in-janusgraph/69238423#69238423 – Kelvin Lawrence Oct 05 '21 at 13:20
  • Hi @KelvinLawrence thanks for your suggestion I have added examples and steps as well thanks – Anish Giri Oct 05 '21 at 14:10
  • Checking back to see if you got your query working? If not, as far as sample steps something closer to the ones shown in the link I pasted above would be more helpful than code snippets as a small sample graph makes testing any potential answers possible. – Kelvin Lawrence Oct 20 '21 at 13:10

0 Answers0