예제 #1
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))
예제 #2
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))
예제 #3
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)
예제 #4
0
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]
예제 #5
0
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]
예제 #6
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)
예제 #7
0
def setup_func () :
    global g
    g = regular_tree(Tree(), 0, nb_vertices=19)
예제 #8
0
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))
예제 #9
0
def setup_func():
    global g
    g = regular_tree(Tree(), 0, nb_vertices=19)
예제 #10
0
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))