Just working with the TinkerGraph, and attempting to recursively find nodes connected by a specific edge label (in this case created
).
3
value).Extra kudos for deduplicating nodes, and handling node loops.
compile("com.thinkaurelius.titan:titan-berkeleyje:0.5.4")
compile('com.tinkerpop:gremlin-groovy:2.6.0')
Gremlin.load()
def g = TinkerGraphFactory.createTinkerGraph()
println g.v(5).as('x')
.both('created')
.dedup
.loop(2){it.loops <= 3}
.path
.toList().flatten() as Set // groovy code to flatten & dedup
[v[5], v[4], v[3], v[1], v[6]]
Thanks!
You don't need any Groovy code, it can be done by only using Gremlin:
gremlin> g.v(5).as('x').both('created').dedup()
gremlin> .loop('x') {true} {true}.dedup()
==>v[4]
==>v[3]
==>v[5]
==>v[6]
==>v[1]