Neptune graph traversal that uses dynamically calculated values from last vertex to select outgoing edges for further traversal

Here is my graph:

Here is graph building code:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> Vertex a = g.addV("Person")
.property(T.id, "A")
.next();
Vertex b = g.addV("Person")
.property(T.id, "B")
.next();
Vertex c = g.addV("Person")
.property(T.id, "C")
.next();
Vertex d = g.addV("Person")
.property(T.id, "D")
.next();
Vertex e = g.addV("Person")
.property(T.id, "E")
.next();
Vertex r1 = g.addV("Right")
.property(T.id, "1")
.property(VertexProperty.Cardinality.set, "types", 1)
.property(VertexProperty.Cardinality.set, "types", 2)
.next();
Vertex r2 = g.addV("Right")
.property(T.id, "2")
.property(VertexProperty.Cardinality.set, "types", 2)
.property(VertexProperty.Cardinality.set, "types", 3)
.next();
Vertex r3 = g.addV("Right")
.property(T.id, "3")
.property(VertexProperty.Cardinality.set, "types", 4)
.property(VertexProperty.Cardinality.set, "types", 5)
.next();
Vertex r4 = g.addV("Right")
.property(VertexProperty.Cardinality.set, "types", 3)
.property(T.id, "4")
.next();
g.addE("receives").from(r1).to(a)
.property(T.id, "a")
.next();
g.addE("receives").from(b).to(r1)
.property(T.id, "b")
.next();
g.addE("receives").from(r2).to(b)
.property(T.id, "c")
.next();
g.addE("receives").from(r3).to(b)
.property(T.id, "d")
.next();
g.addE("receives").from(d).to(r3)
.property(T.id, "e")
.next();
g.addE("receives").from(c).to(r2)
.property(T.id, "f")
.next();
g.addE("receives").from(r4).to(c)
.property(T.id, "g")
.next();
g.addE("receives").from(e).to(r4)
.property(T.id, "h")
.next();
</code>
<code> Vertex a = g.addV("Person") .property(T.id, "A") .next(); Vertex b = g.addV("Person") .property(T.id, "B") .next(); Vertex c = g.addV("Person") .property(T.id, "C") .next(); Vertex d = g.addV("Person") .property(T.id, "D") .next(); Vertex e = g.addV("Person") .property(T.id, "E") .next(); Vertex r1 = g.addV("Right") .property(T.id, "1") .property(VertexProperty.Cardinality.set, "types", 1) .property(VertexProperty.Cardinality.set, "types", 2) .next(); Vertex r2 = g.addV("Right") .property(T.id, "2") .property(VertexProperty.Cardinality.set, "types", 2) .property(VertexProperty.Cardinality.set, "types", 3) .next(); Vertex r3 = g.addV("Right") .property(T.id, "3") .property(VertexProperty.Cardinality.set, "types", 4) .property(VertexProperty.Cardinality.set, "types", 5) .next(); Vertex r4 = g.addV("Right") .property(VertexProperty.Cardinality.set, "types", 3) .property(T.id, "4") .next(); g.addE("receives").from(r1).to(a) .property(T.id, "a") .next(); g.addE("receives").from(b).to(r1) .property(T.id, "b") .next(); g.addE("receives").from(r2).to(b) .property(T.id, "c") .next(); g.addE("receives").from(r3).to(b) .property(T.id, "d") .next(); g.addE("receives").from(d).to(r3) .property(T.id, "e") .next(); g.addE("receives").from(c).to(r2) .property(T.id, "f") .next(); g.addE("receives").from(r4).to(c) .property(T.id, "g") .next(); g.addE("receives").from(e).to(r4) .property(T.id, "h") .next(); </code>
    Vertex a = g.addV("Person")
            .property(T.id, "A")
            .next();
    Vertex b = g.addV("Person")
            .property(T.id, "B")
            .next();
    Vertex c = g.addV("Person")
            .property(T.id, "C")
            .next();
    Vertex d = g.addV("Person")
            .property(T.id, "D")
            .next();
    Vertex e = g.addV("Person")
            .property(T.id, "E")
            .next();


    Vertex r1 = g.addV("Right")
            .property(T.id, "1")
            .property(VertexProperty.Cardinality.set, "types", 1)
            .property(VertexProperty.Cardinality.set, "types", 2)
            .next();
    Vertex r2 = g.addV("Right")
            .property(T.id, "2")
            .property(VertexProperty.Cardinality.set, "types", 2)
            .property(VertexProperty.Cardinality.set, "types", 3)
            .next();
    Vertex r3 = g.addV("Right")
            .property(T.id, "3")
            .property(VertexProperty.Cardinality.set, "types", 4)
            .property(VertexProperty.Cardinality.set, "types", 5)
            .next();
    Vertex r4 = g.addV("Right")
            .property(VertexProperty.Cardinality.set, "types", 3)
            .property(T.id, "4")
            .next();


    g.addE("receives").from(r1).to(a)
            .property(T.id, "a")
            .next();
    g.addE("receives").from(b).to(r1)
            .property(T.id, "b")
            .next();
    g.addE("receives").from(r2).to(b)
            .property(T.id, "c")
            .next();
    g.addE("receives").from(r3).to(b)
            .property(T.id, "d")
            .next();
    g.addE("receives").from(d).to(r3)
            .property(T.id, "e")
            .next();
    g.addE("receives").from(c).to(r2)
            .property(T.id, "f")
            .next();
    g.addE("receives").from(r4).to(c)
            .property(T.id, "g")
            .next();
    g.addE("receives").from(e).to(r4)
            .property(T.id, "h")
            .next();

My requirement is to traverse the graph from A to E, checking the types property of Right vertices for intersections along the way – if the types intersect with the types from last step then select the edge for traversal, otherwise stop ignoring the Right where the types do not intersect.

Here is what I tried so far:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>g.V("A")
.repeat(
inE("receives").outV().as("lastRight").inE("receives").outV()
.inE("receives").outV().as("thisRight").inE("receives").outV()
.simplePath()
)
.until(or(
inE().hasLabel("receives").count().is(0),
loops().is(10)
))
.path()
.toList();
</code>
<code>g.V("A") .repeat( inE("receives").outV().as("lastRight").inE("receives").outV() .inE("receives").outV().as("thisRight").inE("receives").outV() .simplePath() ) .until(or( inE().hasLabel("receives").count().is(0), loops().is(10) )) .path() .toList(); </code>
g.V("A")
.repeat(
  inE("receives").outV().as("lastRight").inE("receives").outV()
 .inE("receives").outV().as("thisRight").inE("receives").outV()
 .simplePath()
)
.until(or(
  inE().hasLabel("receives").count().is(0),
  loops().is(10)
))
.path()
.toList();

There are 2 problems with this query:

  1. It does not do the filtering using intersections between one Right and another along the Path
  2. It its current version – without the filtering using intersections – it should discover 2 paths, one from A – D and one from A to E – it discovers only one A – D. If I simplify the traversal query in the repeat statement, it does find 2 but I need to keep it complex to get a reference to the last Right vertex traversed along the path so I can reason about its types…

Can I achieve such dynamic, step-scoped filtering using intersections with Gremlin in Neptune?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật