gpt4 book ai didi

Gremlin - 类型错误 : Object of type GraphTraversal is not JSON serializable

转载 作者:行者123 更新时间:2023-12-04 13:58:02 24 4
gpt4 key购买 nike

下面这段 gremlin 代码在 gremlin 控制台中运行得非常好(它找到了 k-step ego 网络的唯一起点和终点,以及到该端点的最小距离):

g.V(42062000).as("from")
.repeat(both().as("to")).emit().times(3).path()
.count(local).as("pathlen")
.select("from", "to", "pathlen")
.dedup("from", "to").toList()

并提供类似于以下内容的输出,这是预期的:
==>{from=v[42062000], to=v[83607800], plen=2}
==>{from=v[42062000], to=v[23683248], plen=3}
==>{from=v[42062000], to=v[41762840], plen=3}
==>{from=v[42062000], to=v[42062000], plen=3}
==>{from=v[42062000], to=v[83599456], plen=3}

但是,当将代码转换为符合 gremlinpython 包装器时
(即在用 as 替换 as_ 之后),我得到了错误 TypeError: Object of type GraphTraversal is not JSON serializable ,即使它是相同的查询。

有没有人遇到过类似的问题?

我正在使用 gremlinpython 3.4.2,但最初使用的是 3.3.3。我的 Python 版本是 3.7.3。

最佳答案

进口static类使用

from gremlin_python import statics

statics.load_statics(globals())
或者
from gremlin_python.process.graph_traversal import elementMap, range_, 
local, count
和普通 reserved单词必须以 _ 结尾
例子:
as_, range_

关于Gremlin - 类型错误 : Object of type GraphTraversal is not JSON serializable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57115147/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com