コード例 #1
0
def test_floyd():
    tt = Timetrip(4)
    for w in '0 2 0\n2 2 -1\n2 1 0'.split('\n'):
        tt.fill_graph(w)

    dist, via = tt.floyd()
    assert tt.has_cycle(via) == True
コード例 #2
0
def test_minus_cycle2():
    tt = Timetrip(4)
    for w in '0 0 -2\n0 3 1\n2 3 1\n3 2 2\n2 1 0'.split('\n'):
        tt.fill_graph(w)

    dist, via = tt.floyd()
    print(via)
    assert tt.has_cycle(via) == True

    solution = tt.solve()
    assert solution == ('INFINITY', 'INFINITY')