예제 #1
0
파일: test_gg_basic.py 프로젝트: schmir/gg
def test_get_reachable_from():
    g = gg.graph()
    g.add_link(1, 2)
    g.add_link(1, 3)
    g.add_link(2, 4)
    res = g.get_reachable_from(gg.intvector([1]))
    assert set(res) == set([1, 2, 3, 4])

    res = g.get_reachable_from(gg.intvector([4]))
    assert set(res) == set([4])
예제 #2
0
파일: test_gg_basic.py 프로젝트: schmir/gg
def test_get_reachable_from_cyclic():
    g = gg.graph()
    g.add_link(1, 2)
    g.add_link(2, 3)
    g.add_link(3, 1)
    res = g.get_reachable_from(gg.intvector([1]))
    assert set(res) == set([1, 2, 3])
예제 #3
0
파일: perftest.py 프로젝트: schmir/gg
def perf_reachable():
    stime = time.time()
    g = build_graph().g
    print "build graph", time.time() - stime, len(g)

    stime = time.time()
    res = g.get_reachable_from(gg.intvector([1]))
    print "get_reachable", time.time() - stime, len(res)
예제 #4
0
파일: test_gg_basic.py 프로젝트: schmir/gg
def test_get_links_from_boolvector_empty(small):
    cids = gg.intvector()
    allowed = gg.boolvector()
    small.get_links_from(cids, allowed)
    assert list(allowed) == [False] * 5

    allowed[1] = True
    small.get_links_from(cids, allowed)
    assert list(allowed) == [False, True, False, False, False]
예제 #5
0
파일: test_gg_basic.py 프로젝트: schmir/gg
def test_get_links_from_boolvector(small):
    cids = gg.intvector([3, 5])
    allowed = gg.boolvector()
    small.get_links_from(cids, allowed)
    assert list(allowed) == [False, True, False, False, True]
    assert list(cids) == [3, 5]

    allowed = gg.boolvector()
    cids.append(1)
    small.get_links_from(cids, allowed)

    assert list(allowed) == [False, True, True, False, True]
예제 #6
0
파일: test_gg_basic.py 프로젝트: schmir/gg
def test_get_links_from_allowed(small):
    cids = gg.intvector([3, 5])
    result = gg.boolvector()
    allowed = gg.boolvector()
    small.get_links_from(cids, result, allowed)
    assert list(result) == [False, False, False, False, False]

    allowed.resize(10)
    small.get_links_from(cids, result, allowed)
    assert list(result) == [False, False, False, False, False]

    allowed[1] = True
    small.get_links_from(cids, result, allowed)
    assert list(result) == [False, True, False, False, False]

    for i in range(10):
        allowed[i] = True
    small.get_links_from(cids, result, allowed)
    assert list(result) == [False, True, False, False, True]
예제 #7
0
파일: test_gg_basic.py 프로젝트: schmir/gg
def test_intvector_init_from_list():
    g = gg.intvector(range(100))
    assert list(g) == range(100)
예제 #8
0
파일: test_gg_basic.py 프로젝트: schmir/gg
def test_intvector_empty_init():
    g = gg.intvector()
    assert list(g) == []
예제 #9
0
파일: test_gg_basic.py 프로젝트: schmir/gg
def test_intvector_append():
    g = gg.intvector()
    for i in range(1000):
        g.append(i)

    assert list(g) == range(1000)
예제 #10
0
파일: test_gg_basic.py 프로젝트: schmir/gg
def test_get_links_from_boolvector_return(gr):
    allowed = gg.boolvector()
    cids = gg.intvector()
    cids.append(1)
    res = gr.get_links_from(cids, allowed)
    assert res is allowed
예제 #11
0
파일: test_gg_basic.py 프로젝트: schmir/gg
def test_get_reachable_from_multiple_parents():
    g = gg.graph()
    g.add_link(1, 3)
    g.add_link(2, 3)
    res = g.get_reachable_from(gg.intvector([1, 2]))
    assert list(res) == [1, 2, 3]
예제 #12
0
파일: test_gg_basic.py 프로젝트: schmir/gg
def test_get_reachable_from_empty_graph():
    g = gg.graph()
    res = g.get_reachable_from(gg.intvector(range(10)))
    assert list(res) == range(10)