Hi,
I am new to Gremlin and I am still exploring how to do things, and I hope you don't mind me asking question that may seem trivial to experienced Gremlin users.
I like to collect all the visited vertices in traversal order rather than just outputting the paths.
E.g. given the following example graph:
ex = TinkerGraph.open()
v1 = ex.addVertex(T.label, 'n', 'text', 'cake', 'pos', 1)
v2 = ex.addVertex(T.label, 'n', 'text', 'pizza', 'pos', 2)
v3 = ex.addVertex(T.label, 'n', 'text', 'apple', 'pos', 3)
v4 = ex.addVertex(T.label, 'n', 'text', 'orange', 'pos', 4)
v5 = ex.addVertex(T.label, 'n', 'text', 'fish', 'pos', 5)
v6 = ex.addVertex(T.label, 'n', 'text', 'ham', 'pos', 6)
e1 = v2.addEdge('p', v1)
e2 = v3.addEdge('p', v2)
e2 = v4.addEdge('q', v2)
e3 = v5.addEdge('p', v3)
e3 = v6.addEdge('p', v3)
g = ex.traversal()
and the following traversal:
tx.V().hasLabel('n').repeat(__.in('p').hasLabel('n').order().by('pos', incr)).emit().dedup().simplePath().path().by('text')
I get the output:
==>[cake,pizza]
==>[cake,pizza,apple]
==>[cake,pizza,apple,fish]
==>[cake,pizza,apple,ham]
However, I want to find [cake,pizza,apple,fish,ham], which represents all visited vertices in traversal order of the largest subgraph when traversing tx.V().hasLabel('n').repeat(__.in('p').hasLabel('n').order().by('pos', incr)).emit(), i.e. [cake, pizza, apple] is considered subgraph that I like to filter out. The result I am looking for is not found above because its not really the "path" element I should output, and the dedup is probably also misplaced, but I can't seem to get my head around how to express this in a simple way with Gremlin. I somehow need to collapse the above output into [cake,pizza,apple,fish,ham]. I would appreciate if someone could guide me, and please let me know if the question is in any way unclear.
Thanks,
Mario