gpt4 book ai didi

python - Gremlin Python : Returning vertex IDs and edge properties in a list

转载 作者:行者123 更新时间:2023-11-30 22:11:26 25 4
gpt4 key购买 nike

我很难返回我正在寻找的确切信息。本质上,我想返回某种类型的所有边(任一方向)。我想获取列表中的顶点 ID 和边参数。理想情况下,我的输出格式如下所示:

{
"from": "vertex_id_1",
"to": "vertex_id_2",
"similarity": 0.45
}

我一直在使用 g.both().vertexMap().toList() 来获取相似性,但我无法通过这种方式获取顶点 ID。

最佳答案

以玩具图为例,您最好使用 project() 来实现此目的:

gremlin> g.V().bothE('knows').
......1> project('from','to','weight').
......2> by(outV().id()).
......3> by(inV().id()).
......4> by('weight')
==>[from:1,to:2,weight:0.5]
==>[from:1,to:4,weight:1.0]
==>[from:1,to:2,weight:0.5]
==>[from:1,to:4,weight:1.0]

关于python - Gremlin Python : Returning vertex IDs and edge properties in a list,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51409040/

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