Generating a LabelledBinaryTree from its string representation
t = Permutation([1, 3, 2]).increasing_tree() print t print t.parent()
1[., 2[3[., .], .]] Labelled binary trees
Conversely, I would like to generate a labelled binary tree from its string representation.
s = "1[., 2[3[., .], .]]" LabelledBinaryTree(s)
ValueError: malformed string
How do I have to proceed?
EDIT: I will turn now my question into a feature request:
Make all trees reconstructable by their string representation!
This would be a great help for developing and testing one's code. Below Maybeso83 demonstrates how this can be done for labelled binary trees.