Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MRCA algorithm can be faster #99

Open
niemasd opened this issue Sep 11, 2018 · 1 comment
Open

MRCA algorithm can be faster #99

niemasd opened this issue Sep 11, 2018 · 1 comment

Comments

@niemasd
Copy link

niemasd commented Sep 11, 2018

From what I understand from the mrca() function of a Tree object (https://github.com/jeetsukumaran/DendroPy/blob/master/src/dendropy/datamodel/treemodel.py#L3953), the current algorithm performs a top-down traversal of the tree and returns the last node it sees that has all user-specified taxa as descendants

I believe a faster algorithm (which is what I have implemented in TreeSwift) is the following:

for each node u:
    u.num_descendants = 0
for each leaf l:
    for each ancestor a of l:
        a.num_descendants += 1
        if a.num_descendants == total number of leaves:
            return a
@jeetsukumaran
Copy link
Owner

Thanks for this. Will look into this later!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants