def test_add_tree(): t1 = regular_tree(Tree(), 0, nb_vertices=20) t2 = regular_tree(Tree(), 0, nb_vertices=18) t = t1.copy() n1 = len(t1) n = len(t1) + len(t2) t1.add_child_tree(20, t2) assert len(t1) == n t1.remove_tree(21) assert list(pre_order(t,0)) == list(pre_order(t1,0))
def test_add_tree(): t1 = regular_tree(Tree(), 0, nb_vertices=20) t2 = regular_tree(Tree(), 0, nb_vertices=18) t = t1.copy() n1 = len(t1) n = len(t1) + len(t2) t1.add_child_tree(20, t2) assert len(t1) == n t1.remove_tree(21) assert list(pre_order(t, 0)) == list(pre_order(t1, 0))
def test_preorder(): g = regular_tree(Tree(), 0, nb_vertices=50) l = list(pre_order(g, g.root)) assert len(l) == len(g) for i, vid in enumerate(l): if vid != g.root: assert g.parent(vid) in l[:i], 'vid: '+str(vid) + ' i: ' +str(i)+' : '+ str(l)
def test_postorder(): g = regular_tree(Tree(), 0, nb_vertices=50) l = list(post_order(g, g.root)) assert len(l) == len(g) for i, vid in enumerate(l): if vid != g.root: assert g.parent(vid) not in l[:i]
def test_preorder(): g = regular_tree(Tree(), 0, nb_vertices=50) l = list(pre_order(g, g.root)) assert len(l) == len(g) for i, vid in enumerate(l): if vid != g.root: assert g.parent(vid) in l[:i], 'vid: ' + str(vid) + ' i: ' + str( i) + ' : ' + str(l)
def setup_func () : global g g = regular_tree(Tree(), 0, nb_vertices=19)
def test_levelorder(): g = regular_tree(Tree(), 0, nb_vertices=50) l = list(level_order(g, g.root)) assert len(l) == len(g) assert l == range(len(g))
def setup_func(): global g g = regular_tree(Tree(), 0, nb_vertices=19)