I'm new to graphs and Gremlin API although I find it promising for my purpose so I am investigating and despite looking at documentation and several tutorials, I can't seem to find how to do this.
A portion of my graph would have vertices representing "documents" with "id" (1, 2, 3, ...) and "author" (a: Luc, Kim, ...) properties. They are linked with simple "next" edges. Like this:
V1{a:'Luc'} -> V2{a:'Kim'} -> V3{a:'Marc'} -> V4{a:'Kim'} -> V5{a:'Luc'} -> V6{a:'Luc'}
What I am trying to do:
- start at any known location from the vertice id (eg.: V(2))
- go either "up" with in() or "down" with out() (eg.: out())
- somehow "collect" the ids of vertices that have their author part of an array (eg.: ['Luc', 'Kim'])
- keep going until I have collected at most a certain number of ids (which will, in most cases be smaller than the number of vertices I will traverse to collect them), or until I reach the end (eg.: maximum 3)
So for this example, I would expect the result to be: [2, 4, 5].
From what I found so far, I would have something like:
g.V(2).repeat(somethingThatKeepsTheIdIfAuthorIsInArray(['Luc', 'Kim']).out()).until("I have found 3 ids")
Or if I word it differently, I want to "skip" vertex 3 because its author is not in the list, but keep going until I find at most 3 vertices that match my condition or I reach then end.
Any idea of what step(s) I should be looking at to accomplish this ?