forked from SongDark/FPgrowth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtry.py
31 lines (25 loc) · 834 Bytes
/
try.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
class treeNode:
def __init__(self, nameValue, numOccur, parentNode):
self.name = nameValue
self.count = numOccur
self.nodeLink = None
self.parent = parentNode
self.children = {}
def inc(self, numOccur):
self.count += numOccur
def disp(self, ind=1):
print ' '*ind, self.name, ' ', self.count
for child in self.children.values():
child.disp(ind+1)
def updateHeader(nodeToTest, targetNode):
while nodeToTest.nodeLink != None:
nodeToTest = nodeToTest.nodeLink
nodeToTest.nodeLink = targetNode
header = treeNode("None", 0, None)
header.disp()
node1 = treeNode("one", 1, None)
updateHeader(header, node1)
header.nodeLink.disp()
node2 = treeNode("two", 1, None)
updateHeader(header, node2)
header.nodeLink.nodeLink.disp()