# HG changeset patch
# User darij grinberg <darijgrinberg@gmail.com>
# Date 1362209209 28800
# Node ID 2138739627609b648a2268e4d72dccafb95e02ae
# Parent 4725d5410950f729bc7e687e404893f04292c7d9
[mq]: trac_8703trees_addition2dg.patch
diff git a/sage/combinat/abstract_tree.py b/sage/combinat/abstract_tree.py
a

b

class AbstractLabelledTree(AbstractTree) 
810  810  
811  811  def as_digraph(self): 
812  812  """ 
813   Returns a directed graph version of ``self`` 
 813  Returns a directed graph version of ``self``. 
 814  
 815  WARNING: 
 816  At this time, the output makes sense only if ``self`` is a 
 817  labelled binary tree with no repeated labels and no "None" 
 818  labels. 
814  819  
815  820  EXAMPLES:: 
816  821  
diff git a/sage/combinat/binary_tree.py b/sage/combinat/binary_tree.py
a

b

from sage.misc.lazy_attribute import laz 
111  111  
112  112  class BinaryTree(AbstractClonableTree, ClonableArray): 
113  113  """ 
114   The class of binary trees 
 114  The class of binary trees. Binary trees here mean ordered (aka plane) 
 115  binary trees, meaning that the children of each node are ordered. 
115  116  
116  117  INPUT: 
117  118  
118  119   ``children``  ``None`` (default) or a list, tuple or iterable of 
119   length 2 of binary trees or convertible objects. Alternatively a string 
120   is also accepted. The syntax is the same as for printing: empty trees 
121   are denoted by `.` and children are grouped by square brackets. 
 120  length 2 of binary trees or convertible objects. This corresponds to 
 121  the standard recursive definition of a binary tree as either a leaf 
 122  or a pair of binary trees. Syntactic sugar allows leaving out all 
 123  but the outermost calls of the ``BinaryTree()`` constructor, so that, 
 124  e. g., ``BinaryTree([BinaryTree(None),BinaryTree(None)])`` can be 
 125  simplified to ``BinaryTree([None,None])``. It is also allowed to 
 126  abbreviate ``[None, None]`` by ``[]``. 
122  127  
123  128   ``check``  (default to ``True``) whether check for binary should be 
124  129  performed or not. 
… 
… 
class BinaryTree(AbstractClonableTree, C (this hunk was shorter than expected) 
131  136  
132  137  sage: BinaryTree() 
133  138  . 
 139  sage: BinaryTree(None) 
 140  . 
 141  sage: BinaryTree([]) 
 142  [., .] 
134  143  sage: BinaryTree([None, None]) 
135  144  [., .] 
136  145  sage: BinaryTree([None, []]) 
… 
… 
class BinaryTree(AbstractClonableTree, C 
436  431   a leaf is associated to the empty Dyck Word 
437  432  
438  433   a tree with chidren `l,r` is associated to the Dyck word 
439   `1 T(l) 0 T(r)` where `T(l)` and `T(r)` are the trees 
 434  `1 T(l) 0 T(r)` where `T(l)` and `T(r)` are the Dyck words 
440  435  associated to `l` and `r`. 
441  436  
442  437  EXAMPLES:: 
… 
… 
class BinaryTree(AbstractClonableTree, C 
458  453  The *canopee* of a non empty binary tree `T` with `n` internal nodes is 
459  454  the list `l` of `0` and `1` of length `n1` obtained by going along the 
460  455  leaves of `T` from left to right except the two extremal ones, writing 
461   `0` if the leaf is a right leaf and `1` is a left leaf. 
 456  `0` if the leaf is a right leaf and `1` if the leaf is a left leaf. 
462  457  
463  458  EXAMPLES:: 
464  459  
diff git a/sage/combinat/ordered_tree.py b/sage/combinat/ordered_tree.py
a

b

class OrderedTree(AbstractClonableTree, 
26  26  """ 
27  27  The class for (ordered rooted) Trees 
28  28  
29   An ordered tree is a constructed from a node called the root on which one 
 29  An ordered tree is constructed from a node called the root on which one 
30  30  has grafted a possibly empty list of trees. There is a total order on the 
31   children of a node which is given by the the order of the element in the 
 31  children of a node which is given by the order of the element in the 
32  32  list. Note that there is no empty ordered tree. 
33  33  
34  34  INPUT: 
35  35  One can create a tree from any list (or more generally iterable) of trees 
36  36  or objects convertible to a tree. Alternatively a string is also 
37  37  accepted. The syntax is the same as for printing: children are grouped by 
38  38  square brackets. 
 39  Ordered trees are occasionally called plane trees in literature. 
39  40  
40  41  EXAMPLES:: 
41  42  
42  43  