I have a JanusGraph with vertices containing property key "ID" and edges labelled as "ML_EDGE", containing property key "STRENGTH".
I have to start from a vertex and traverse the graph based on the edges which has highest the "STRENGTH".
The following query works fine.
g.V().has('ID','id').repeat(outE("ML_EDGE").has("STRENGTH",gt(0)).limit(1).inV()).times(3);
But I have to stop traversal when a leaf vertex in encountered. So I made some changes.
g.V().has('ID','id').repeat(outE("ML_EDGE").has("STRENGTH",gt(0)).limit(1).inV()).until(or(loops().is(eq(2)),outE().count().is(eq(0))))
This query returns empty result.
Also, with the first query, I tried replacing times() with until() and got the query,
g.V().has('ID','id').repeat(outE("ML_EDGE").has("STRENGTH",gt(0)).limit(1).inV()).until(loops().is(eq(1)));
It doesn't work either.
I am a newbie to JanusGraph and I am stuck. Any help to fix this would be life-saving.
Use of optional() in repeat() solved the issue.
Hope this would solve the problem.