-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTreeNode.py
50 lines (38 loc) · 1.11 KB
/
TreeNode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'''
Created on Oct 20, 2013
@author: anchalagarwal
'''
class TreeNode(object):
'''
classdocs
'''
def __init__(self, Word):
self.ParentNodesList = []
self.ChildNodesList = []
self.word = Word
def appendParent(self,parentTuple):
self.ParentNodesList.append(parentTuple)
return
def appendChild(self,childTuple):
self.ChildNodesList.append(childTuple)
return
def returnParents(self):
return self.ParentNodesList
def returnChild(self):
return self.ChildNodesList
def removeChild(self,child):
self.ChildNodesList.remove(child)
return self
def removeParent(self,parent):
self.ParentNodesList.remove(parent)
return self
def removemychild(self,child):
for i in self.ChildNodesList:
if i[0] == child:
self.removeChild(i)
return
def removemyparent(self,parent):
for i in self.ParentNodesList:
if i[0] == parent:
self.removeParent(i)
return