Beispiel #1
0
def test_lcaFind4():
    dg = lca.DirectedGraph()
    n1 = dg.newNode(1)
    n2 = dg.newNode(2)
    n3 = dg.newNode(3)
    n4 = dg.newNode(4)
    n5 = dg.newNode(5)
    n6 = dg.newNode(6)
    n7 = dg.newNode(7)
    n8 = dg.newNode(8)
    n9 = dg.newNode(9)
    n10 = dg.newNode(10)
    n11 = dg.newNode(11)
    n12 = dg.newNode(12)
    n1.pointsTo(n2)
    n1.pointsTo(n3)
    n2.pointsTo(n4)
    n2.pointsTo(n5)
    n3.pointsTo(n6)
    n3.pointsTo(n7)
    n4.pointsTo(n8)
    n4.pointsTo(n9)
    n5.pointsTo(n10)
    n5.pointsTo(n11)
    n6.pointsTo(n12)
    assert dg.findLCA(n10, n2) == 2
Beispiel #2
0
def test_common4():
    dg = lca.DirectedGraph()

    list1 = None
    list2 = None

    common = dg.commonElements(list1, list2)
    assert common == []
Beispiel #3
0
def test_common3():
    dg = lca.DirectedGraph()

    list1 = []
    list2 = []

    common = dg.commonElements(list1, list2)
    assert common == []
Beispiel #4
0
def test_common2():
    dg = lca.DirectedGraph()

    list1 = [1, 2, 3, 4, 5, 6]
    list2 = [7, 8, 9]

    common = dg.commonElements(list1, list2)
    assert common == []
Beispiel #5
0
def test_common1():
    dg = lca.DirectedGraph()

    list1 = [1, 2, 3, 4, 5, 6]
    list2 = [6, 5, 4, 3, 2]

    common = dg.commonElements(list1, list2)
    assert common == [2, 3, 4, 5, 6]
Beispiel #6
0
def test_lcaFind5():
    dg = lca.DirectedGraph()
    n1 = dg.newNode(1)
    n2 = dg.newNode(2)
    n3 = dg.newNode(3)
    n1.pointsTo(n3)
    n1.pointsTo(n2)
    assert dg.findLCA(n2, n2) == 2
Beispiel #7
0
def test_lcaFind8():
    dg = lca.DirectedGraph()
    n1 = dg.newNode(1)
    n2 = dg.newNode(2)
    n3 = dg.newNode(3)
    n4 = dg.newNode(4)
    n1.pointsTo(n2)
    n2.pointsTo(n3)
    n3.pointsTo(n4)
    n4.pointsTo(n1)
    assert dg.findLCA(n1, n2) == 1
Beispiel #8
0
def test_lcaFind9():
    dg = lca.DirectedGraph()
    n1 = dg.newNode(1)
    n2 = dg.newNode(2)
    n3 = dg.newNode(3)
    n4 = dg.newNode(4)
    n5 = dg.newNode(5)
    n6 = dg.newNode(6)
    n1.pointsTo(n2)
    n1.pointsTo(n3)
    n4.pointsTo(n5)
    n4.pointsTo(n6)
    assert dg.findLCA(n2, n6) == -1
Beispiel #9
0
def test_lcaFind2():
    dg = lca.DirectedGraph()
    n1 = dg.newNode(1)
    n2 = dg.newNode(2)
    n3 = dg.newNode(3)
    n4 = dg.newNode(4)
    n5 = dg.newNode(5)
    n6 = dg.newNode(6)
    n7 = dg.newNode(7)
    n1.pointsTo(n2)
    n1.pointsTo(n3)
    n2.pointsTo(n4)
    n2.pointsTo(n5)
    n3.pointsTo(n6)
    n3.pointsTo(n7)
    assert dg.findLCA(n5, n7) == 1
Beispiel #10
0
def test_lcaFind10():
    dg = lca.DirectedGraph()
    n1 = None
    n2 = None

    assert dg.findLCA(n1, n2) == -1