简体   繁体   English

边缘列表中的边缘 - gremlin python

[英]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.

相关问题 gremlin-python在一次交易中删除多个顶点和边 - gremlin-python drop multiple vertices and edges in one transaction 无法使用 Python 将顶点或边添加到 CosmosDB Gremlin 图 SDK - Cannot add vertices or edges to CosmosDB Gremlin graph with Python SDK Gremlin python 合并边缘 - Gremlin python coalesce for edges 如何通过gremlin-python获取所有边缘,关联的顶点以及相应的id,标签和属性? - How do I get all the edges, associated vertices, and the respective id, label and properties via gremlin-python? 使用gremlin-python过滤列表的边缘作为属性值 - Filter edges with a list as the property value using gremlin-python 如何从python的邻接列表中返回至少具有n条边的顶点列表? - How to return a list of vertices that have at minimum n edges from an adjacency list in python? Blender Python api 顶点、边和面选择 - Blender Python api vertices, edges and faces selection 如何在 Python 中生成 1000 个随机顶点和边? - How to generate 1000 random vertices and edges in Python? Gremlin Python:不可散列的类型:在边缘上使用 groupCount 时的“dict” - Gremlin Python: unhashable type: 'dict' while using groupCount on edges 在 Python 中生成具有平行标记边/顶点的有向图 - Generating Directed Graph With Parallel Labelled Edges/Vertices in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM