ocarina/tests/trees.py

65 lines
1.5 KiB
Python

# Bryan Schumaker (11/06/2010)
from libsaria import trees
#tree = trees.Tree()
#tree.insert(["home", "bjschuma", "Music"])
#tree.insert(["home", "bjschuma", "Videos"])
#tree.insert(["home", "other", "Music"])
#from libsaria import path
#tree = path.make_tree("/home/bjschuma/Music")
#print tree
#print tree.value
#tree.disp()
#for path in tree.walk():
# print path
#tree = trees.DLTree()
#n = tree.insert(["a", "b", "c", "d"])
#o = tree.insert(["a", "b", "c", "e"])
#p = tree.insert(["f", "g", "h", "i"])
#tree.disp()
#print n.walk_backwards()
#print o.walk_backwards()
#print p.walk_backwards()
#tree = trees.DLFSTree()
#n = tree.insert_path("/a/b/c/d")
#o = tree.insert_path("/a/b/c/e")
#p = tree.insert_path("/f/g/h/i")
#
#for path in tree.walk_paths():
# print path
#
#print n.walk_path_backwards()
#print o.walk_path_backwards()
#print p.walk_path_backwards()
#tree = trees.ValTree()
#tree.insert(["a", "b", "c", "d"], [1, 2, 3, 4])
#tree.insert(["a", "b", "c", "e"], [1, 2, 3, 5])
#tree.insert(["f", "g", "h", "i"], [6, 7, 8, 9])
#tree.disp()
#for vals in tree.walk_vals():
# print vals
tree = trees.DLValTree()
n = tree.insert(["a", "b", "c", "d"], [1, 2, 3, 4])
o = tree.insert(["a", "b", "c", "e"], [1, 2, 3, 5])
p = tree.insert(["f", "g", "h", "i"], [6, 7, 8, 9])
tree.disp()
for path in tree.walk_vals():
print path
print n.walk_backwards()
print n.walk_vals_backwards()
print o.walk_backwards()
print o.walk_vals_backwards()
print p.walk_backwards()
print p.walk_vals_backwards()