Reputation: 16364
I am new to Gremlin and am trying to list all the edges that connect a set of nodes:
const vertexes = g.V().where(...).toList()
[1]
[2]
[4]
I want to retrieve all the edges that connect [1],[2] and [4] excluding all the other edges.
For the moment, I wrote the following:
g.V(vertexes).bothE().dedup().toList()
But this command will return all the edges from and to the selected vertexes including edges coming and going to other not selected vertexes.
Upvotes: 0
Views: 47
Reputation: 46226
You just need to filter the edges by the adjacent vertex:
gremlin> g.V(1,2,3).bothE().dedup().where(otherV().hasId(1,2,3))
==>e[9][1-created->3]
==>e[7][1-knows->2]
You can read more about these sorts of patterns in the TinkerPop Gremlin Recipes.
Upvotes: 1