Is there a version of gremlin "bothE" that isn't actually "eitherE"?

105 Views Asked by At

I want to find all vertecies which has an edge to a specific vertex but the vertex should also have an edge back to the other vertex.

The following query does not behave in the way i want, it seems that bothE() means either in or out or both, not explicitly that both an incoming and outgoing edge must be present.

g.V(id).bothE().outV()

I also don't want the starting vertex (g.v(id)) to be returned. I've looked through the documentation but there's so many complex queries available that it'll take me a very long time to find this one simple thing i need. Any help is appreciated

1

There are 1 best solutions below

0
On BEST ANSWER

You need something like this

g.V(id).as('a').out().where(out().as('a'))

Which basically says, find everything I am connected to by an outgoing edge that also has an outgoing edge back to me.