So, itโs obvious that the direct way to find an edge between two vertices is as follows:
graph.traversal().V(outVertex).bothE(edgeLabel).filter(__.otherV().is(inVertex))
I feel that the filter step should iterate around all edges, which makes it very slow for some applications with lots of edges.
Another way:
traversal = graph.traversal() .V(outVertex) .bothE(edgeLabel) .as("x") .otherV() .is(outVertex) // uses index? .select("x");
I assume that the second approach can be much faster, as it will use an ID index, which will make it faster than the first approach.
Which one is faster and more efficient (in terms of IO)?
I use Titan, so you can also make your answer specific with Titan.
Edit
In terms of time, it seems that the first approach is faster (edges were 20k for vertex b
gremlin> clock(100000){gV(b).bothE().filter(otherV().is(a))} ==>0.0016451789999999999 gremlin> clock(100000){gV(b).bothE().as("x").otherV().is(a).select("x")} ==>0.0018231140399999999
What about IO?
source share