【问题标题】:Gremlin Python: Returning vertex IDs and edge properties in a listGremlin Python:在列表中返回顶点 ID 和边属性
【发布时间】:2018-07-18 18:47:35
【问题描述】:

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

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

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

【问题讨论】:

    标签: python graph gremlin amazon-neptune


    【解决方案1】:

    以玩具图为例,您最好使用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]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-14
      • 1970-01-01
      • 2020-09-05
      • 2021-09-08
      • 2022-01-22
      • 2021-12-27
      相关资源
      最近更新 更多