The following are three equivalent representations of the same tree (phylogenetic). I am trying to figure out an algorithm to check if two tree representations are equivalent. Trees are defined to be equivalent if the parent-child relationship between nodes are similar.
(Whale,(Seal,((Mouse,Rat),((((Carp,Loach),Frog),Chicken),Human))),Cow);
(Whale,(Seal,((Rat,Mouse),(Human,((Frog,(Loach,Carp)),Chicken)))),Cow);
((Seal,((Rat,Mouse),(Human,((Frog,(Loach,Carp)),Chicken)))), Cow, Whale);
Can anyone suggest a method?
One way would be to walk the children in lexographical order (or any strict weak ordering) and compare.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With