Plotting LabelledOrderedTrees in Knuth style
Consider the tree
t = Permutation([1,3,2,6,5,7,4]).increasing_tree().as_ordered_tree()
A nice simple plot is given by
ascii_art(t)
_________1___________
/ /
None ___________2_____________
/ /
_3___ ______4_______
/ / / /
None None ____5______ None
/ /
_6___ _7___
/ / / /
None None None None
What I need is a graph-plot in exactly this layout in Knuth style (cf. the tables in 7.2.1.6) where the inner nodes (above labeled by numbers) are filled black disks and the leaves (above labeld by 'None') are empty squares.
How can I achieve this?
There is now also "unicode_art" (not answering the question).
Frédéric, in my jupyter notebook I see no difference although I expected one after looking into abstract_tree.py. What are the requirements?
Ah, I see now, it works with 7.3 (but did not with 7.2). But it does not work with LabelledBinaryTrees. With t = Permutation([1,3,2,6,5,7,4]).increasing_tree() I get the AttributeError 'UnicodeArt' object has no attribute '_root'.
not yet implemented for binary trees, indeed
Maybe you could use "t.map_labels(lambda x: 0 if x in ZZ else 1)" to avoid part of the post-processing.