algorithm - How to solve Subtree Isomorphism using maximum bipartite matching? -
how determine if given tree t contains subtree isomorphic tree s?
two trees called isomorphic if 1 of them can obtained other series of flips, i.e. swapping left , right children of number of nodes. number of nodes @ level can have children swapped. 2 empty trees isomorphic.
i've read @ few places bipartiate matching algorithms can used solve problem can't find non-paywalled sources details. there seems many research papers on problem, of them again behind paywall, i'm not interested in latest research algorithm problem. question how bipartiate matching applies problem?
ps: there seems confusion on internet meant "isomorphic". above definition found @ places places mentioned "isomorphic" means trees of same shape regardless of node values. if can clear confusion, had great too.
i'm going talk rooted subtree isomorphism; unrooted case can handled without regard efficiency trying roots.
the basic idea if have trees
b /|\ /|\ / | \ / | \ / | \ / | \ a1 ... b1 ... bn /\ /\ /\ /\
and want know whether a
subtree of b
in such way a
maps b
, i
, j
, compute recursively whether subtree rooted @ ai
subtree of tree rooted @ bj
in such way ai
maps bj
. (the base cases when a
or b
leaf.) now, it's not enough each subtree mappable, because if bj
has particularly rich structure, several ai
s might subtrees, requirements of isomorphism won't let them share bj
. maximum matching comes in: try match of ai
s bj
s in such way subtrees can mapped.
to general rooted problem, try possible choices of b
.
Comments
Post a Comment