# -*- coding: utf-8 -*- """ Created on Thu Feb 18 23:33:09 2016 @author: alex """ from ObjectClasses import Node, Tree, _KeyAction, _InputParameter, _Workflow #Tree Test node1 = Node() node1.data = 1 node2 = Node() node2.data = 2 node3 = Node() node3.data = 3 node4 = Node() node4.data = 4 node5 = Node() node5.data = 5 tree = Tree() tree.root = node1 tree.root.connections.append(node2) tree.root.connections[0].connections.append(node3) node2.connections.append(node4) node4.connections.append(node5) print(tree.root.data) for con in tree.root.connections: print(con.data)
from Tree_Iterators import Basic_Recursive_Iterator, Advanced_Recursive_Iterator from ObjectClasses import Node, Tree #Define the Recursion Functions def write_test(): print('test') def write_node(node, param): print('%s%s' % (node.data, param)) #Build a few trees to test with node_list=[] i=0 for i in range(0, 30): n = Node() n.data = i node_list.append(n) #Single Stack Test tree1 = Tree() tree1.root = node_list[0] node_list[0].connections.append(node_list[1]) node_list[1].connections.append(node_list[2]) node_list[2].connections.append(node_list[3]) node_list[3].connections.append(node_list[4]) node_list[4].connections.append(node_list[5]) #Bidirectional search tree tree2 = Tree()