EmmanuelOga / hypergraphdb

Automatically exported from code.google.com/p/hypergraphdb
1 stars 0 forks source link

Removal of HGLink should allow targets to be removed #71

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In cases where we implement a HGLink to model composition, we most often wish 
to remove all target atoms when we remove same link.

Let's assume a HGLink "Changeset" that contains "Change" atoms. 
We want to remove Changeset cs, including all target changes c1..n, but no 
incidentLinks.

Currently, to accomplish this, we first iterate over a List "changes" and call 
graph.remove(ccur, true) for each change handle c.
The HG implementation of remove will call notifyTargetRemoved() on cs, which 
will in turn modify the list we are iterating over. 

Therefore we can identify the following inefficiencies:
A) To remove a list of targets, we need a copy of the target handle list we 
iterate over.
B) For each individial remove operation, the link's targetlist will have to 
remove one element on notifyTargetRemoved(), potentially a O(N) operation and 
unnecessary, because we will remove both, the link and the whole list.

We therefore suggest to extend the interface of Hypergraph to include a method 
that allows a link to be removed with its targets, while keeping other incident 
links. It's implementation will avoid inefficient notifyTargetRemoved() calls 
on the link to be removed altogether.

Original issue reported on code.google.com by thomas.h...@gmail.com on 13 Feb 2012 at 7:06