- Added printtree function to print an indented representation of the tree
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@221 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
2c4757dafb
commit
eaa6c4562d
@ -105,8 +105,22 @@ class node (object):
|
|||||||
else:
|
else:
|
||||||
return self.name
|
return self.name
|
||||||
pass
|
pass
|
||||||
|
def printtree(self,level=0):
|
||||||
|
'''Prints a representation of the tree using indentation'''
|
||||||
|
r=''
|
||||||
|
for i in range(level):
|
||||||
|
r+=' '
|
||||||
|
r+=self.name
|
||||||
|
if self.name in b_operators:
|
||||||
|
r+=self.left.printtree(level+1)
|
||||||
|
r+=self.right.printtree(level+1)
|
||||||
|
elif self.name in u_operators:
|
||||||
|
r+='\t%s\n' % self.prop
|
||||||
|
r+=self.child.printtree(level+1)
|
||||||
|
|
||||||
|
return '\n'+r
|
||||||
def get_left_leaf(self):
|
def get_left_leaf(self):
|
||||||
'''This function returns the most left random leaf in the tree. It is needed by some optimizations.'''
|
'''This function returns the most left leaf in the tree. It is needed by some optimizations.'''
|
||||||
if self.kind==RELATION:
|
if self.kind==RELATION:
|
||||||
return self
|
return self
|
||||||
elif self.kind==UNARY:
|
elif self.kind==UNARY:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user