# HG changeset patch
# User darij grinberg
# Date 1362209209 28800
# Node ID 2138739627609b648a2268e4d72dccafb95e02ae
# Parent 4725d5410950f729bc7e687e404893f04292c7d9
[mq]: trac_8703-trees_addition2-dg.patch
diff --git a/sage/combinat/abstract_tree.py b/sage/combinat/abstract_tree.py
--- a/sage/combinat/abstract_tree.py
+++ b/sage/combinat/abstract_tree.py
@@ -810,7 +810,12 @@ class AbstractLabelledTree(AbstractTree)
def as_digraph(self):
"""
- Returns a directed graph version of ``self``
+ Returns a directed graph version of ``self``.
+
+ WARNING:
+ At this time, the output makes sense only if ``self`` is a
+ labelled binary tree with no repeated labels and no "None"
+ labels.
EXAMPLES::
diff --git a/sage/combinat/binary_tree.py b/sage/combinat/binary_tree.py
--- a/sage/combinat/binary_tree.py
+++ b/sage/combinat/binary_tree.py
@@ -111,14 +111,19 @@ from sage.misc.lazy_attribute import laz
class BinaryTree(AbstractClonableTree, ClonableArray):
"""
- The class of binary trees
+ The class of binary trees. Binary trees here mean ordered (aka plane)
+ binary trees, meaning that the children of each node are ordered.
INPUT:
- ``children`` -- ``None`` (default) or a list, tuple or iterable of
- length 2 of binary trees or convertible objects. Alternatively a string
- is also accepted. The syntax is the same as for printing: empty trees
- are denoted by `.` and children are grouped by square brackets.
+ length 2 of binary trees or convertible objects. This corresponds to
+ the standard recursive definition of a binary tree as either a leaf
+ or a pair of binary trees. Syntactic sugar allows leaving out all
+ but the outermost calls of the ``BinaryTree()`` constructor, so that,
+ e. g., ``BinaryTree([BinaryTree(None),BinaryTree(None)])`` can be
+ simplified to ``BinaryTree([None,None])``. It is also allowed to
+ abbreviate ``[None, None]`` by ``[]``.
- ``check`` -- (default to ``True``) whether check for binary should be
performed or not.
@@ -131,15 +136,16 @@ class BinaryTree(AbstractClonableTree, C
sage: BinaryTree()
.
+ sage: BinaryTree(None)
+ .
+ sage: BinaryTree([])
+ [., .]
sage: BinaryTree([None, None])
[., .]
sage: BinaryTree([None, []])
@@ -436,7 +431,7 @@ class BinaryTree(AbstractClonableTree, C
- a leaf is associated to the empty Dyck Word
- a tree with chidren `l,r` is associated to the Dyck word
- `1 T(l) 0 T(r)` where `T(l)` and `T(r)` are the trees
+ `1 T(l) 0 T(r)` where `T(l)` and `T(r)` are the Dyck words
associated to `l` and `r`.
EXAMPLES::
@@ -458,7 +453,7 @@ class BinaryTree(AbstractClonableTree, C
The *canopee* of a non empty binary tree `T` with `n` internal nodes is
the list `l` of `0` and `1` of length `n-1` obtained by going along the
leaves of `T` from left to right except the two extremal ones, writing
- `0` if the leaf is a right leaf and `1` is a left leaf.
+ `0` if the leaf is a right leaf and `1` if the leaf is a left leaf.
EXAMPLES::
diff --git a/sage/combinat/ordered_tree.py b/sage/combinat/ordered_tree.py
--- a/sage/combinat/ordered_tree.py
+++ b/sage/combinat/ordered_tree.py
@@ -26,17 +26,15 @@ class OrderedTree(AbstractClonableTree,
"""
The class for (ordered rooted) Trees
- An ordered tree is a constructed from a node called the root on which one
+ An ordered tree is constructed from a node called the root on which one
has grafted a possibly empty list of trees. There is a total order on the
- children of a node which is given by the the order of the element in the
+ children of a node which is given by the order of the element in the
list. Note that there is no empty ordered tree.
INPUT:
One can create a tree from any list (or more generally iterable) of trees
or objects convertible to a tree. Alternatively a string is also
accepted. The syntax is the same as for printing: children are grouped by
square brackets.
+ Ordered trees are occasionally called plane trees in literature.
EXAMPLES::