顶点列表中的边 - gremlin python

Edges among a list of vertices - gremlin python

我有一个顶点 ID 列表。我想得到它们之间所有可能的边缘。

我知道像 filter/where 这样的方法在这里会有帮助,但由于我使用的是 gremlin-python,它们的实现必须不同。

我试过了:

a = [0,2,4,6,8,10]

g.V(a).outE().inV().hasId(a).toList()
# This gives me []

g.V(a).bothE().filter(otherV().hasId(a)).toSet()
# Traceback otherV is not defined

g.V(a).bothE().otherV().hasId(a).toList()
# This gives me []

# Some information on edges :
g.E().toList()
# [e[16][0-Likes->8], e[17][8-Likes->0], e[18][4-Likes->8], e[19][2-Likes->6], e[20][6-Likes->2], e[21][12-Likes->10], e[22][10-Likes->12], e[23][10-Likes->14], e[24][14-Likes->8], e[25][6-Likes->4]]

我怎样才能做到这一点?看似简单的问题,但我还是卡住了。

有多种方法可以做到这一点 - 这个怎么样?

gremlin> a = ['marko','josh','lop']
==>marko
==>josh
==>lop
gremlin> g.V().has('name',within(a)).
......1>   aggregate('a').
......2>   outE().
......3>   filter(inV().where(within('a')))
==>e[9][1-created->3]
==>e[8][1-knows->4]
==>e[11][4-created->3]

这里以 modern TinkerPop 玩具图为例。首先,我们找到那些起始顶点并将它们聚合到一个名为 "a" 的列表副作用中。然后,我们遍历每个的出边并过滤它们以匹配 "a".

中的那些顶点