簡體   English   中英

Gremlin Python:返回列表中的頂點ID和邊緣屬性

[英]Gremlin Python: Returning vertex IDs and edge properties in a list

我很難回復我正在尋找的確切信息。 基本上,我想返回某種類型的所有邊(在任一方向上)。 我想在列表中獲取頂點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]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM