We use Gremlin 3.2 compatible database. Actually, we try Cosmos DB in graph/gremlin mode. But I am looking to gremlin query so not necessary it is related only to Cosmos DB
The graph looks like on the image below
I have created a query that is able to capture red vertices/nodes.
g.V("A").emit().repeat(__.in('depends')).until(__.inE().count().is(0))
But struggling to extend a query to capture direct children of each vertex. On the image marked as blue ones.
Can anybody help with such a gremlin query?
Here is a query in online editor https://gremlify.com/spml2ktk03 If using the online editor:
You should be able to accomplish what you are looking for by using store() to store all the vertices in the tree and then for each iteration of the repeat you can use sideEffect() to find it's children and store them as well.
g.V().hasLabel('B').store('v').
repeat(__.in('depends').store('v').
sideEffect(out('depends').store('v'))).
until(__.inE().
count().is(0)).cap('v')
This returns me:
B -> A -> C- > D -> E -> TOP