Beispiel #1
0
def test_chain_finding():
    d, ndds = read_with_ndds("test-fixtures/chain-finding")
    chains = k_ndds.find_chains(d, ndds, 3)
    lengths = sorted(len(c.vtx_indices) for c in chains)
    scores = sorted(c.score for c in chains)
    assert lengths == [1, 2, 3]
    assert scores == [1.2, 2.7, 3.7]

    chains = k_ndds.find_chains(d, ndds, 1)
    lengths = sorted(len(c.vtx_indices) for c in chains)
    scores = sorted(c.score for c in chains)
    assert lengths == [1]
    assert scores == [1.2]

    chains = k_ndds.find_chains(d, ndds, 0)
    assert len(chains) == 0
def test_chain_finding():
    d, ndds = read_with_ndds("test-fixtures/chain-finding")
    chains = k_ndds.find_chains(d, ndds, 3)
    lengths = sorted(len(c.vtx_indices) for c in chains)
    scores = sorted(c.score for c in chains)
    assert lengths == [1, 2, 3]
    assert scores == [1.2, 2.7, 3.7]

    chains = k_ndds.find_chains(d, ndds, 1)
    lengths = sorted(len(c.vtx_indices) for c in chains)
    scores = sorted(c.score for c in chains)
    assert lengths == [1]
    assert scores == [1.2]

    chains = k_ndds.find_chains(d, ndds, 0)
    assert len(chains) == 0
def test_counter():
    d, ndds = read_with_ndds("test-fixtures/100-random-weights")
    max_length = 4
    cycles = d.find_cycles(max_length)
    cycle_counts = [0] * (max_length + 1)
    for c in cycles:
        cycle_counts[len(c)] += 1
    eq_(cycle_counts, ccc.count_cycles(d, max_length))

    chains = k_ndds.find_chains(d, ndds, max_length)
    chain_counts = [0] * (max_length + 1)
    for c in chains:
        chain_counts[len(c.vtx_indices)] += 1
    eq_(chain_counts, ccc.count_chains(d, ndds, max_length))
def test_counter():
    d, ndds = read_with_ndds("test-fixtures/100-random-weights")
    max_length = 4
    cycles = d.find_cycles(max_length)
    cycle_counts = [0] * (max_length + 1)
    for c in cycles:
        cycle_counts[len(c)] += 1
    assert cycle_counts == ccc.count_cycles(d, max_length)

    chains = k_ndds.find_chains(d, ndds, max_length)
    chain_counts = [0] * (max_length + 1)
    for c in chains:
        chain_counts[len(c.vtx_indices)] += 1
    assert chain_counts == ccc.count_chains(d, ndds, max_length)