I want to program a tree (in a mathematical view) in Python 2.7 where each vertex is white or black. Then I want to be able to remove leafs to create a new tree. Note that the root can be a leaf if it only has one connection and therefore it can be removed.
Is there some way to find an ID for the tree so I can store values for different trees in a list? I also want to make a loop for different small trees, for examples all trees with 8 or fewer vertices with all possible black-white colorings.
One idea is to start with binary trees since it could be to complex otherwise.
Is there any good structures for this?