Gremlin Statement for Adding Edges Based on Existence of Other Edges
I'm trying to figure out how to do the following in Gremlin with Kelvin's air-routes data. I want to be able to add direct flights (edge with route label) from airports (vertex with airport label) that currently have routes that are exactly two degrees away but currently don't have a direct connecting route. Is it possible to do this in one statement?
2 Replies
Speaking in terms of the modern graph, starting with "vadas" two steps away are these vertices:
we obviously don't want to traverse back to "vadas" so we filter him (for simplicity sake i filter v[3] as well given directionality):
then we want to make sure that these two vertices have no direct link back to "vadas":
finally, we add the shortcut edge back to "vadas":
Thanks Stephen. I didn't think to use filtering with an alias.