【问题标题】:Is there a way to store more information on the Edges of Amazon Neptune Graph?有没有办法在 Amazon Neptune Graph 的边缘存储更多信息?
【发布时间】:2020-04-07 03:27:06
【问题描述】:

我正在做一个小型 POC 项目,我想使用 Amazon 的 Neptune Graph 来表示一个村庄的道路网络。

我打算将交叉点用作此图中的顶点,并将街道用作边缘。一个简单的表示是:

Intersection {
   id: 1089238983,
   name: 'Madrid & 99th'
   labels: ['has_pedestrian_signals', 'four_way_intersection']
}

Street {
   id: 9808787868,
   name: 'Madrid St'
   from_int_id: 1089238983,
   to_int_id: 1089238973, 
   labels: ['has_hospital_on_street', 'is_snow_route', 'is_one_way_street']
}

问题是 AWS's documentation 声明边只能有 1 个标签。

我希望最终能够根据边的属性执行遍历。我尝试寻找将更多数据合并到 Tinkerpop 图表中的方法,但没有发现任何有用的东西。

如果有任何建议,我将不胜感激。

【问题讨论】:

    标签: amazon-web-services gremlin tinkerpop amazon-neptune


    【解决方案1】:

    Gremlin 确实支持边缘属性,就像顶点属性一样。 http://tinkerpop.apache.org/docs/3.4.6/reference/#addedge-step

    // define 'a' and 'b' vertices
    g.addE('friendlyCollaborator').from('a').to('b').
                     property(id,23).property('project',select('c').values('name'))
    

    唯一需要注意的是,与仅读取边缘标签相比,获取边缘属性是一个额外的跳跃。

    例如:

    g.V(1).outE('knows') -> Gets the matching out edge in 2 hops.
    g.V(1).outE().hasProperty('knows') -> An added hop to get to your edge.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-20
      • 2020-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-24
      • 2022-10-25
      相关资源
      最近更新 更多