Hey all,
GremlinPipeline<Vertex,List> pipe = new GremlinPipeline<Vertex,List>().start(v1).as("x").out("friend").
loop("x", new PipeFunction<LoopPipe.LoopBundle<Vertex>, Boolean>(){
public boolean compute(LoopBundle<Vertex> bundle)
{
if(!bundle.getObject().getId().equals(v2.getId()))
return true;
else
return false;
}
}).path();
It works fine. With
while(pipe.hasNext())
System.out.println(l.next());
Trouble is, this query is very slow because it computes all the paths between two vertices. What I would ideally like to do is force a breadth first search and terminate the loop the first time v2 is encountered. That way all possible paths are not explored.
I have arequirement to compute shortest path from about 100 nodes to 300,000 nodes in my graph.
The time this takes just wont do.
How do I implement a BFS through gremlin java and terminate the loop at the first encounter of v2?
Thanks,
Aparna