标签: graphexp

使用 Gremlin-python 和 graphexp 匿名生成子遍历

我正在尝试从头开始创建一个在 graphexp 中可视化的图表,但我正在努力理解匿名遍历的概念以及如何创建它们

我正在使用 python 3.9 和 gremlinpython 3.5.1

  • 创建连接和图表:
from gremlin_python.process.anonymous_traversal import traversal

self.g = traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin', 'g'))
Run Code Online (Sandbox Code Playgroud)
  • 我导入了静态数据,这样我就可以使用没有 __ 类的步骤:
statics.load_statics(globals())
Run Code Online (Sandbox Code Playgroud)
  • 如果顶点不存在则创建它:
def _add_vertex(self, name):
        return self.g.V().has('name', name).fold().coalesce(unfold(), addV().property('name',name)).next()
Run Code Online (Sandbox Code Playgroud)
  • 如果两个顶点之间不存在边,则创建边:
def _add_edge(self, v1, v2, weight, label):
        return self.g.V(v1).as_("fromVertex").V(v2).coalesce(inE(label).where(outV().as_(
            "fromVertex")), addE(label).property("weight", weight).from_("fromVertex")).next()
Run Code Online (Sandbox Code Playgroud)

但是当我点击一个顶点时,我在 graphexp 中遇到了这个错误

Error retrieving data
The child traversal of [GraphStep(vertex,[696560]), PropertyMapStep(value)] was not spawned anonymously - use the __ class rather than a TraversalSource to construct the child traversal
Run Code Online (Sandbox Code Playgroud)

该文档总体不错,但对于匿名遍历部分没有太大帮助。那么如何使用这种方法生成匿名子遍历呢?它的真正含义是什么?

python gremlin janusgraph graphexp gremlinpython

2
推荐指数
1
解决办法
740
查看次数

标签 统计

graphexp ×1

gremlin ×1

gremlinpython ×1

janusgraph ×1

python ×1