-
My question concerns deleting an edge. Suppose I have the RID of the head vertex and the RID of the tail vertex and the name of the EdgeType. What is the best way to find and then delete the edge in Java code and what is the complexity of doing so? Does it have to iterator over all the edges connected to the head vertex to find it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
@benanavd I'd say that is the least efficient way to find an edge in a graph database :-) In that case, you're right, you should start from the head or tail and look for the edge. The best would be having its RID so the complexity would be A solution would be to create an index on the edge on Example:
You can omit UNIQUE if you can have multiple edges between the same vertices. Creating a unique index on edge out+in is useful to guarantee you have only one edge, so it works as a constraint. The only cons of having an index on edge's out+in is the insertion will be slower, because an index must be updated every time. |
Beta Was this translation helpful? Give feedback.
@benanavd I'd say that is the least efficient way to find an edge in a graph database :-) In that case, you're right, you should start from the head or tail and look for the edge. The best would be having its RID so the complexity would be
O(log1)
. In your case would beO(log1)
to look up for the head or tail vertex + browse the edges. Then, the edges in the list are not sorted, so it depends on how many edges you have.A solution would be to create an index on the edge on
@out
and@in
, so you can use the index to look up the edge quickly.Example:
You can omit UNIQUE if you can have multiple edges between the same vertices. C…