예제 #1
0
def test_bellman_ford_negative():
    """Bellman Ford algorithm test with negative cycle"""
    graph = SimpleGraph([('a', 'b', -1), ('b', 'a', -3), ('a', 'g', 1),
                         ('g', 'b', 1)])
    assert graph.bellmanford('a') == 'Graph contains a negative-weight cycle'
예제 #2
0
def test_bellman_ford():
    """basic Bellman Ford algorithm test"""
    graph = SimpleGraph([('a', 'b', 6), ('b', 'a', 5), ('a', 'g', 1),
                         ('g', 'b', 1)])
    assert graph.bellmanford('a') == {'a': 0, 'b': 2, 'g': 1}