You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure whether this is expected behaviour or not. I have two trees. One tree is basically the subtree of another where some nodes are dropped (B, C, E) and where one node has shifted a level(L).
fromzssimportsimple_distance, NodeOPERATIONS= {
0: 'remove',
1: 'insert',
2: 'update',
3: 'match'
}
A= (
Node("A")
.addkid(Node("B"))
.addkid(Node("C"))
.addkid(Node("D")
.addkid(Node("E"))
.addkid(Node("F"))
.addkid(Node("G")
.addkid(Node("H"))
.addkid(Node("I")))
.addkid(Node("J")
.addkid(Node("K"))))
.addkid(Node("L"))
)
B= (
Node("D")
.addkid(Node("F"))
.addkid(Node("G")
.addkid(Node("H"))
.addkid(Node("I")))
.addkid(Node("J")
.addkid(Node("K")))
.addkid(Node("L"))
)
dist, opts=simple_distance(A, B, return_operations=True)
print(dist)
# expected to have the same number operations as the max number of items in the treeprint(len(opts))
foroptinopts:
s=OPERATIONS[opt.type]
ifopt.arg1isnotNone:
s+=f"\t{opt.arg1.label}"ifopt.arg2isnotNone:
s+=f"\t{opt.arg2.label}"print(s)
Printed output:
5.0
10
remove E
match F F
match H H
match I I
match G G
match K K
match J J
remove D
match L L
update A D
When looking at the operations, though, I don't see any operations done on the labels 'B' and 'C'. Is that specific to the algorithm or the implementation?
As a comparison, here is the output of the same tree comparison with APTED:
There was an error in my initial code of the APTED example. Now they do behave the same. The only difference seems to be that zss doesn't return all operations, unless I am missing something.
BramVanroy
changed the title
Subtree matching, nodes are ignored
Subtree matching, not all operations are returned
Jan 27, 2020
The operations code was a external feature contribution (and I have to admit I haven't used it). There could very well be a bug in it -- and it certainly looks like B and D should have been removed. Since the distance being returned is correct my guess is the operations mapping is not correct.
The operations code was a external feature contribution (and I have to admit I haven't used it). There could very well be a bug in it -- and it certainly looks like B and D should have been removed. Since the distance being returned is correct my guess is the operations mapping is not correct.
I think so, too. Unfortunately I don't have the time to look further into this. As per your suggestion over email, I will use APTED in the future.
I'm not sure whether this is expected behaviour or not. I have two trees. One tree is basically the subtree of another where some nodes are dropped (B, C, E) and where one node has shifted a level(L).
Printed output:
When looking at the operations, though, I don't see any operations done on the labels 'B' and 'C'. Is that specific to the algorithm or the implementation?
As a comparison, here is the output of the same tree comparison with APTED:
Output of apted:
Thanks in advance!
The text was updated successfully, but these errors were encountered: