Ask Your Question

Obtaining all posets from binary trees up to isomorphism

asked 2020-10-25 18:43:45 -0600

klaaa gravatar image

updated 2020-10-26 04:07:21 -0600

FrédéricC gravatar image

One can obtain all posets of binary trees for a given n as follows in Sage:

posets = [bt.to_poset() for bt in BinaryTrees(n)]

Is there a quick method to obtain the list of all such posets up to isomorphism?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2020-10-26 04:05:47 -0600

FrédéricC gravatar image

Make your own iterator:

def tree_iter(n): 
    if n  == 0: 
        yield BinaryTree() 
    for k in range(n): 
        if k > n - k: 
        for t1 in tree_iter(k): 
            for t2 in tree_iter(n - 1 - k): 
                s1 = t1.to_dyck_word() 
                s2 = t2.to_dyck_word() 
                if k < n - k or s1 <= s2: 
                    yield BinaryTree([t1, t2])
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-10-25 18:43:45 -0600

Seen: 46 times

Last updated: Oct 26