0

Sample graph of what I'm building

I want to fetch all the students connected to a particular school. The students, however, can be present at any depth in the graph (with respect to the school). Ideally, I want to filter the students through the incoming-edge (named 'STUDENT' in this case)

  • 1
    You will definitely find lots of great help here when it comes to Gremlin. It would really help though if you could provide a sample graph snippet so that you can get answers in context. A sample can be as simple as a bit of Gremlin that just does a series of addV() and addE() steps such as g.addV('root').property('data',9).as('root'). addV('node').property('data',5).as('b'). addV('node').property('data',2).as('c'). addV('node').property('data',16).as('j'). addE('left').from('root').to('b').iterate() – Kelvin Lawrence Dec 06 '18 at 15:13

1 Answers1

1

Assuming that only class and student labels can be found along the path:

g.V().has('school','name','Gremlin School').
  repeat(out('class','student')) /* labels refer to edge labels  */
    until(hasLabel('student'))   /* label refers to vertex label */
Daniel Kuppitz
  • 10,846
  • 1
  • 25
  • 34