Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien Boussicault committed Feb 9, 2015
1 parent 250b639 commit e92d96b
Showing 1 changed file with 97 additions and 1 deletion.
98 changes: 97 additions & 1 deletion src/sage/combinat/non_ambiguous_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,17 @@ class NonAmbiguousTree( ClonableList ):
EXAMPLES::
sage: nat = NonAmbiguousTree(
....: [
....: [1,0,1,1,0],
....: [0,0,1,0,0],
....: [1,1,0,0,1],
....: [0,0,1,0,0]
....: ]
....: )
sage: nat
0[2[., 1[., 4[., .]]], 2[1[3[., .], .], 3[., .]]]
sage: nat = NonAmbiguousTree(
....: [
....: [1,1,0,1,0],
Expand Down Expand Up @@ -347,6 +358,21 @@ def posets_of_nodes( self ):
return _posets_of_nodes( self.get_tree() )

def get_tree( self ):
r'''
Return the labeled tree associated with the non-ambiguous tree.
EXAMPLES::
sage: nat = NonAmbiguousTree(
....: [
....: [1,1,0,1,0],
....: [1,0,1,0,1],
....: [0,1,0,0,0]
....: ]
....: )
sage: nat.get_tree()
0[1[., 2[., 4[., .]]], 1[2[., .], 3[., .]]]
'''
return self[0]

def get_permutation_of_left_and_right_sons( self ):
Expand Down Expand Up @@ -578,6 +604,34 @@ def get_right_permutation( self ):

@combinatorial_map(name = "To binary tree")
def to_binary_tree( self ):
r'''
Return the binary tree of the non ambiguous tree
EXAMPLES::
sage: nat = NonAmbiguousTree(
....: [
....: [1,0,1,1,0],
....: [0,0,1,0,0],
....: [1,1,0,0,1],
....: [0,0,1,0,0]
....: ]
....: )
sage: nat.to_binary_tree()
[[., [., [., .]]], [[[., .], .], [., .]]]
sage: nat = NonAmbiguousTree( [ [1] ] )
sage: nat.to_binary_tree()
[., .]
sage: nat = NonAmbiguousTree( [ [1, 1] ] )
sage: nat.to_binary_tree()
[., [., .]]
sage: nat = NonAmbiguousTree( [ [1], [1] ] )
sage: nat.to_binary_tree()
[[., .], .]
'''
return BinaryTree( self.get_tree() )

def _recursive_check(
Expand Down Expand Up @@ -695,9 +749,39 @@ def _recursive_binary_tree( array, position=[0,0], node_type=None ):
self._options = None

def left_node_number( self ):
r'''
Return the number of left sons in the non-ambiguous tree.
The number of left sons is equal to the height - 1.
EXAMPLES::
sage: nat = NonAmbiguousTree(
....: [ [1,1,0,1,0], [1,0,1,0,1], [0,1,0,0,0] ]
....: )
sage: nat.left_node_number()
2
sage: nat.left_node_number() == nat.height() - 1
True
'''
return self.get_tree().left_node_number()

def right_node_number( self ):
r'''
Return the number of right sons in the non-ambiguous tree.
The number of right sons is equal to the width - 1.
EXAMPLES::
sage: nat = NonAmbiguousTree(
....: [ [1,1,0,1,0], [1,0,1,0,1], [0,1,0,0,0] ]
....: )
sage: nat.right_node_number()
4
sage: nat.right_node_number() == nat.width() - 1
True
'''
return self.get_tree().right_node_number()

def width( self ):
Expand Down Expand Up @@ -1145,7 +1229,19 @@ def _latex_list( self ):

def get_options( self ):
r'''
Return all the opitons of the object.
Return all the options of the object.
Examples::
sage: nat = NonAmbiguousTree(
....: [ [1,1,0,1,0], [1,0,1,0,1], [0,1,0,0,0] ]
....: )
sage: o = nat.get_options()
sage: o
options for Non-ambiguous Trees
sage: o()
Current options for Non-ambiguous Trees
...
'''
if self._options is None:
return self.parent().get_options()
Expand Down

0 comments on commit e92d96b

Please sign in to comment.