コード例 #1
0
def test_adjacent_returns_false_if_specific_pair_of_values_has_no_edge(num):
    """Test adjacent is false if pair of values given doesn't exist in graph as edge."""
    from weight_graph import Graph
    g = Graph()
    for x in range(num):
        g.add_edge(x, x + 1, x % 3 + 1)
    for x in range(num - 1):
        assert not g.adjacent(x, x + 2)
コード例 #2
0
def test_adjacent_returns_true_if_specific_pair_of_values_given_exist(num):
    """Test adjacent is true if pair of values given exist in graph as edge."""
    from weight_graph import Graph
    g = Graph()
    for x in range(num):
        g.add_edge(x, x + 1, x % 3 + 1)
    for x in range(num):
        assert g.adjacent(x, x + 1)