Hey,
> I am trying to get a labeled edge between to vertices in Java and I am not sure the best way to do this. I have the IDs of both vertices and the label of the edge between them and if they are connected I want to get back the edge.
In Gremlin:
g.v(1).outE('mylabel').inV.has('id',2).back(2)
1. g.v(1) - your start vertex
2. outE('mylabel') - get the outgoing edges with label 'mylabel'
3. inV - get the incoming/head vertex of the edge
4. has('id',2) - filter all vertices that don't have id 2 (the end vertex)
5. back(2) - go back to the edges whose paths were not filtered.
In Gremlin-Java:
Iterable<Edge> edges = new GremlinPipeline(graph.getVertex(1)).outE("mylabel").inV.has("id",2).back(2)
In Blueprints-Java:
List<Edge> edges = new ArrayList<Edge>();
for(Edge edge : graph.getVertex(1).getEdges(Direction.OUT)) {
if(edge.getVertex(Direction.IN).getId().equals(2)) {
edges.add(edge.getVertex(Direction.IN));
}
}
HTH,
Marko.
http://thinkaurelius.com