Exemplo n.º 1
0
def test_connect():
    """
    This test assures that a connection is being made from Edge 1 to 2.
    """
    graph = Graph('')
    e1 = graph.add(Edge('', 1, 1))
    e2 = graph.add(Edge('', 2, 1))
    graph.connect(e1, e2)
    assert graph[e2] == []
    assert graph[e1] == [e2]
Exemplo n.º 2
0
def test_can_t_connect_twice():
    """
    This test assures that edges which already have been connected will
    not result in an additional edge again.
    """
    graph = Graph('')
    e1 = Edge('', 1, 1)
    e2 = Edge('', 1, 2)
    for i in range(5):
        graph.connect(e1, e2)

    assert graph[e1] == [e2]
Exemplo n.º 3
0
 def setUp(self):
     self.graph = Graph('foo')
Exemplo n.º 4
0
def test_repr():
    graph = Graph('foo')
    graph.add(Edge('o', 3, 4))
    expected = '<Graph foo [(<Edge o at #3@4>, [])]>'
    assert expected == repr(graph)