Hi there,
I've come to the most interesting part of my project - traversing graph.
Now I'm investigating how I can find
1. All paths between 2 vertices
2. Shortest path between 2 vertices. If I can solve the first problem, this won't be an issue.
3. Get related vertices to vertex V with given depth D of relationship.
I've come across with SELECT .. TRAVERSE query. But it's still unclear for me, how it works in general.
And how I can find all paths using this query in particular.
Also, I'm looking in using Gremlin for these problems.
I came up with this piece of code
OrientGraph graph = DatabaseManager.getInstance().getDatabase("remote:
192.168.200.1/ePersona").getConnection();
final Vertex v = graph.getVertex("#21:14");
GremlinPipeline pipe = new GremlinPipeline(graph.getVertex("#21:7")).as("person");
List path = pipe.both("RELATED").loop("person", new PipeFunction<LoopPipe.LoopBundle, Boolean>() {
@Override
public Boolean compute(LoopPipe.LoopBundle loopBundle) {
return loopBundle.getLoops() <5 && !((Vertex)loopBundle.getObject()).getId().toString().equals("#21:14") ;
}
}).path().toList();
Trying to find all paths between vertices #21:14 and #21:7. I've got 3634 of vertices and 12572 edges in my DB, this query has been working for 15 minutes for now and I don't think it'll be done any time soon.
This means I'm stuck again.
Any comments, suggestions are very welcome!
-Andrey