gremlin-python-获取大于两条边的节点

gremlin-python-gets nodes with greater than two edges

我目前正在使用 gremlin-python 研究图表。我想让所有顶点都有两个以上的出边。我正在使用匿名遍历根据边数过滤掉用户,但下面是我得到的错误。

A​​ttributeError: 'list' 对象没有属性 'out'

我是新手,不确定我做错了什么。这是有限的 gremlin-pythontutorials/docs 中描述的方式。

如果您可以包含一个显示您使用的导入以及查询的代码片段,将会很有帮助。在您的 Python 代码中,您是否记得导入此 class?

from gremlin_python.process.graph_traversal import __

我可以运行使用我的一张图表

你的查询没有任何问题
g.V().hasLabel('airport').where(__.out().count().is_(P.gte(2))).count().next()

如果您没有该导入,您将看到与您看到的错误类似的错误。

有一个使用 gremlin-python 时最常需要的导入列表 at this location

编辑添加:

正如 Stephen 在下面的评论中指出的那样,您只需要知道是否至少有两个传出边,您可以通过添加limit步。

g.V().hasLabel('airport').where(__.out().limit(2).count().is_(P.gt(1))).count().next()