How to implement propagation algorithms in Neptune

0

I need to implement a custom propagation algorithm that starts from a given node and visits its neighbors and update their properties accordingly based on the previous node properties. Example use case is, a quality flag that changed in a given node from good to bad and I need to make all the subsequent nodes become bad.

What is the recommend way of implement this efficiently in Neptune? (I'm trying to avoid to have client code to have this graph traversal one hop at a time)

질문됨 2년 전256회 조회
1개 답변
1

So something like the following?

Sample graph:

g.addV('Product').property(id,'prod1').property('name','widget').property('quality','good').as('p1').
addV('Product').property(id,'prod2').property('name','sproket').property('quality','good').as('p2').
addV('Product').property(id,'prod3').property('name','screw').property('quality','good').as('p3').
addV('Product').property(id,'prod4').property('name','bolt').property('quality','good').as('p4').
addE('connectedTo').from('p1').to('p2').
addE('connectedTo').from('p1').to('p3').
addE('connectedTo').from('p1').to('p4')

Sample query:

g.V('prod1').as('p1').property(single,'quality','bad').
    out('connectedTo').
    property(single,'quality',select('p1').values('quality'))

This query would alter the property on the "root" vertex and apply the same property value to the children vertices.

UPDATE: If wanting to propagate this down an entire tree, you could use a repeat() step:

g.V('prod1').as('p1').property(single,'quality','bad').
    repeat(
        out('connectedTo').
        property(single,'quality',select('p1').values('quality'))
    )
profile pictureAWS
답변함 2년 전
  • interesting so I can make search query and then basically call property on the traversal to set the value of the property!

  • Is this recursing or it will just propagate to direct children of p1, I see you only use out not sure if this will grab all subsequent nodes (i.e. children of children)

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠