[英]Edges among a list of vertices - gremlin python
I have a list of vertex ids. 我有一个顶点ID列表。 I want to get all possible edges among them. 我想在他们中间获得所有可能的优势。
I understand methods like filter/where would be of help here, but since I'm using gremlin-python, their implementation must be different. 我理解像filter这样的方法会在这里提供帮助,但由于我使用的是gremlin-python,它们的实现必须是不同的。
I have tried : 我努力了 :
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]]
How can I achieve this? 我怎样才能做到这一点? It seems like an easy problem, but still I am stuck on it. 这似乎是一个简单的问题,但我仍然坚持下去。
There are number of ways to do this - how about this one? 有很多方法可以做到这一点 - 这个怎么样?
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]
This used the modern TinkerPop toy graph as an example. 这使用现代 TinkerPop玩具图作为例子。 First, we find those starting vertices and aggregate them to a list side-effect called "a". 首先,我们找到那些起始顶点并将它们聚合到名为“a”的列表副作用。 Then, we traverse the outgoing edges of each and filter them for matches with those vertices in "a". 然后,我们遍历每个的传出边缘并过滤它们以匹配“a”中的那些顶点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.