Removing/Deleting an Edge in Java

476 views
Skip to first unread message

Guruprasad Nagaraj

unread,
May 13, 2015, 3:34:26 PM5/13/15
to orient-...@googlegroups.com
Version: 2.0.M1
Graph API

Hi,
I need to delete an edge in a method, and I have the following as parameters into the method - instance of the source OrientVertex, instance of the target OrientVertex and the name of the edge class which binds them together.

I looked at the example given http://orientdb.com/docs/last/orientdb.wiki/SQL-Delete-Edge.html, but couldn't match it with the methods in version 2.0.M1.
Is there a way that I can retrieve just that one edge between the two vertices and remove it?

Thanks and Best Regards,
GPN

W. Craig Trader

unread,
May 13, 2015, 11:52:16 PM5/13/15
to orient-...@googlegroups.com
Have a look at the code examples attached to this issue (https://github.com/orientechnologies/orientdb/issues/4105). The example code shows ways to locate an edge, in order to update its properties, but once you've located it, you can delete it as well.

The simple (no indexes) implementation is this:

String type;
OrientVertex src,  tgt;

for (Edge edge : src.getEdges( tgt, Direction.BOTH, type ) ) {
    OrientEdge e = (OrientEdge) edge;
    e.remove();
    break;
}

This is fine as long as you don't have a lot of edges on the source node; if you have a lot of edges associated with a given node, you'll want to use heavyweight edges, index them, and then you can use OrientBaseGraph::getEdges() to search using the index for your edge and then remove it.  (See the linked code for details).

- Craig -

--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages