I'm trying to find the shortest path between two Vertices (fromNode and toNode) in Tinkerpop 3, with the limitation that I need to stop searching after at some depth N. Without this limitation I'll never finish as the graph is too large.
So far this the best I can come up with:
titanGraph.traversal().V(fromNode)
.repeat(out().simplePath())
.times(N)
.emit(hasId(toNode)).path();
The problem that this has, and all other ways I've tried, is that the paths of length N are returned as results, even when they don't reach toNode.
I need to return all paths between fromNode and toNode of length N or under.
You were on the right track
titanGraph.traversal().V(fromNode)
.repeat(out().simplePath())
.times(N)
.emit(hasId(toNode)).hasId(toNode).path();