I have the following code snippet which I use to find the shortest path between two nodes:
GremlinPipeline<String, List> pathPipe = new GremlinPipeline<String, List>(v1)
.as("similar")
.out("similar")
.loop("similar", new PipeFunction<LoopBundle<Vertex>, Boolean>() {
//@Override
public Boolean compute(LoopBundle<Vertex> bundle) {
return bundle.getLoops() < 5 && bundle.getObject() != v2;
}
})
.path()
Now I wonder how can I print the results. I try this:
Iterator iter = pathPipe.iterator();
while(iter.hasNext()) {
System.out.println(iter.next());
}
But I have the following strange results:
[v[#9:0], v[#9:1], v[#9:0]]
[v[#9:0], v[#9:1], v[#9:2]]
[v[#9:0], v[#9:1], v[#9:3]]
[v[#9:0], v[#9:1], v[#9:4]]
[v[#9:0], v[#9:1], v[#9:5]]
[v[#9:0], v[#9:1], v[#9:6]]
[v[#9:0], v[#9:1], v[#9:7]]
[v[#9:0], v[#9:1], v[#9:8]]
[v[#9:0], v[#9:1], v[#9:9]]
[v[#9:0], v[#9:1], v[#9:10]]
[v[#9:0], v[#9:1], v[#9:11]]
[v[#9:0], v[#9:1], v[#9:12]]
[v[#9:0], v[#9:1], v[#9:13]]
[v[#9:0], v[#9:1], v[#9:14]]
[v[#9:0], v[#9:1], v[#9:15]]
[v[#9:0], v[#9:1], v[#9:16]]
Note that I am trying to find the shortest path between nodes v[#9:0] and v[#9:1].
Is there a problem on my find shortest path code or there is an other way to print my results?
I use oriented 1.6.2.