从一组顶点中获取所有边

Get all the edges from a set of vertexes

我是 Gremlin 的新手,正在尝试列出连接一组节点的所有边:

const vertexes = g.V().where(...).toList()
[1]
[2]
[4]

我想检索连接 [1]、[2] 和 [4] 的所有边,不包括所有其他边。

目前,我写了以下内容:

g.V(vertexes).bothE().dedup().toList()

但是此命令将 return 所有来自和到达选定顶点的边,包括到达和到达其他未选定顶点的边。

你只需要通过相邻的顶点过滤边缘:

gremlin> g.V(1,2,3).bothE().dedup().where(otherV().hasId(1,2,3))
==>e[9][1-created->3]
==>e[7][1-knows->2]

您可以在 TinkerPop Gremlin Recipes.

中阅读更多关于此类模式的信息