Just working with the TinkerGraph, and attempting to recursively find nodes connected by a specific edge label (in this case created
).
- Is there a way I can recursively(/loop) traverse nodes? In the example below, I want to loop until there are no more matching edges (instead of the hardcoded
3
value). - Is there anyway to find and group connected Vertices, given a graph?
Extra kudos for deduplicating nodes, and handling node loops.
Dependencies
compile("com.thinkaurelius.titan:titan-berkeleyje:0.5.4")
compile('com.tinkerpop:gremlin-groovy:2.6.0')
Code (manually recurse 3 times :( )
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
Gives me: (correct)
[v[5], v[4], v[3], v[1], v[6]]
Thanks!