I want to remove edge between two vertices, so my code in java tinkerpop3 as below
private void removeEdgeOfTwoVertices(Vertex fromV, Vertex toV,String edgeLabel,GraphTraversalSource g){
if(g.V(toV).inE(edgeLabel).bothV().hasId(fromV.id()).hasNext()){
List<Edge> edgeList = g.V(toV).inE(edgeLabel).toList();
for (Edge edge:edgeList){
if(edge.outVertex().id().equals(fromV.id())) {
TitanGraph().tx();
edge.remove();
TitanGraph().tx().commit();
return;//Remove edge ok, now return.
}
}
}
}
Is there a simpler way to remove edge between two vertices by a direct query to that edge and remove it? Thank for your help.