Hi,
Assuming following schema
VertexA--edgeAB-->VertexB
VertexA--edgeAC-->VertexC
VertexC--edgeCB-->VertexB
Traversalstep 1: start with VertexB,
step 2: traverse edgeAB to find connected VertexA,
step 3: traverse edgeAC to find connected VertexC
step 4: how to filter out VertexC which are not connect to VertexB from step 1 ?
Gremlin queries that i tried:g.V().hasLabel("VertexB").as("B").in("edgeAB").out("edgeAC").where(__.out("edgeCB").is("B"))
g.V().hasLabel("VertexB").as("B").in("edgeAB").out("edgeAC").where(__.out("edgeCB").hasId(__.select("B").id()))
Expected result: list of VertexC vertices which are connect back to the same VertexB vertex from step 1
Actual result: empty
Solution from the JanusGraph forum which works:
g.V().hasLabel("VertexB").as("B").in("edgeAB").out("edgeAC").as("C").out("edgeCB").as("B2").where("B", eq("B2")).select("C")
Couple of questions:
1. Is there a more efficient gremlin than the solution mentioned above?
2. why does the where traversal approach e.g. where(__.out("edgeCB").is("B")) not work. Is it because "B" is considered as a literal instead of step label?
Thanks,
Ronnie