【问题标题】:Gremlin strategy to vertex peer sharing exactly the same neighbourhood顶点对等点共享完全相同邻域的 Gremlin 策略
【发布时间】:2019-09-02 12:13:34
【问题描述】:

使用 AWS Neptune,我需要找到一种遍历策略,该策略采用一个参考顶点,并通过沿一种边缘类型遍历,找到具有完全相同邻居的另一个顶点,即。不多也不少。

g.V('1').as('ref_vertex').out('created').as('creations').in('created')

查找也创建了与“1”相同的东西的顶点,但它也在顶点范围内(a)也创建了其他东西,以及(b)那些没有创建“1”创建的所有东西的顶点。

g.V('1').as('ref_vertex')
 .out('created').as('creations').in('created')
 .not(out('created').where(neq('creations'))

只解决问题 (a),摆脱人创造了一些额外的东西。

如何继续此查询以从结果中跳过 (b) 顶点?

【问题讨论】:

标签: gremlin traversal amazon-neptune neighbours


【解决方案1】:
g.V('1').aggregate('ref_vertex').
    out('created').
    sideEffect(aggregate('neighbors')).     /* get neighbors of 'ref_vertex' */
    in('created').groupCount().unfold().    /* group count in('created') by its occurrence times */
    as('candidate_shared_neighbor_cnt_pair').
    where('candidate_shared_neighbor_cnt_pair', eq('neighbors')).       /* select only the vertices have the same occurrence times as 'ref_vertex' */
        by(select(values)).
        by(unfold().count()).
    select(keys).
    where(without('ref_vertex'))

【讨论】:

  • 好吧,我的脑子已经炸了:) 谢谢你的回复,我需要考虑清楚。这种技术将如何防止假同行,例如。共享一个共同的创造,但除此之外,ref 和 peer 也创造了 2-2 个其他不同的东西,所以它们会通过,因为创造计数是相等的?
  • @BalazsDavidMolnar if ref -> c1, m1, m2;假对等-> c1,n1,n2。那么 'neighbors' 包含 [c1, m1, m2],但在 'candidate_shared_neighbor_cnt_pair' 中,由于 fake-peer 只出现一次,所以值为 1,不等于 sizeof('neighbors')
猜你喜欢
  • 2019-01-06
  • 1970-01-01
  • 2015-03-09
  • 1970-01-01
  • 1970-01-01
  • 2020-07-30
  • 1970-01-01
  • 2013-01-18
  • 2022-01-22
相关资源
最近更新 更多