DatabaseGroup / apted

APTED algorithm for the Tree Edit Distance
http://tree-edit-distance.dbresearch.uni-salzburg.at/
MIT License
115 stars 34 forks source link

NodeIndexer's postL_to_node is not returning the proper node. #5

Closed mausotog closed 6 years ago

mausotog commented 6 years ago

I am trying to use Apted, but I think the NodeIndexer is not returning the proper node. I have two trees were the only difference is that one node was deleted from the source tree. String sourceTree = "{A{B{X}{Y}{F}}{C}}"; String destinationTree = "{A{B{X}{Y}}{C}}";

I compute the edit distance and create the edit mapping.

float ed = apted.computeEditDistance(source, dest); LinkedList<int[]> em = apted.computeEditMapping();

I get a proper mapping saying that node 3 (3 as in the index of that node when indexed in post order) was deleted, so far so good. The problem comes when I want to find which node is node 3 (which should be "{F}"). The way I am trying to do this is by creating a NodeIndexer and using method postL_to_node to look for node 3. NodeIndexer<Node, CostModel> niSource = new NodeIndexer(source, myCM); Node node = niSource.postL_to_node(3);

and I get that node 3 is "{B{X}{Y}{F}}" which is not "{F}",the node deleted. I would like to know if this is a bug in postL_to_node, or maybe there is an easier way to look for a particular node from the mapping (a function that I input 3 and gives me Node {F}).

Thanks in advance

problemWithNodeIndexer.txt

mateuszpawlik commented 6 years ago

To make it short. In the mapping output, the node ids start with 1 because 0 represents deletion or insertion. It may be misleading but it's documented in the help message. Node with id 3 is then the F.

This is the mapping representation of your input.

mapping