Exemplo n.º 1
0
    def test_5(self):
        V = ['a', 'b', 'c', 'd', 'e', 'f']
        E = [('f', 'a'), ('f', 'b'), ('a', 'd'), ('b', 'd'), ('d', 'c'),
             ('c', 'e'), ('e', 'a')]
        graph = MathGraph(V, E)

        self.assertRaises(ValueError, build_order, graph)
Exemplo n.º 2
0
    def test_4(self):
        V = ['a', 'b', 'c', 'd', 'e', 'f']
        E = [('f', 'a'), ('f', 'b'), ('a', 'd'), ('b', 'd'), ('d', 'c')]
        graph = MathGraph(V, E)

        build = build_order(graph)
        self.assertEqual(build, ['e', 'f', 'a', 'b', 'd', 'c'])
Exemplo n.º 3
0
    def test_1(self):
        V = [1, 2, 3]
        E = [(1, 2), (1, 3), (2, 3)]
        graph = MathGraph(V, E)

        build = build_order(graph)
        self.assertEqual(build, [1, 2, 3])
Exemplo n.º 4
0
    def test_1(self):
        V = [1, 2]
        E = [(1, 2)]
        G = MathGraph(V, E)

        self.assertTrue(exists_route(G, 1, 2))
        self.assertFalse(exists_route(G, 2, 1))
        self.assertFalse(exists_route(G, 1, 1))
        self.assertFalse(exists_route(G, 2, 2))
Exemplo n.º 5
0
    def test_2(self):
        V = [1, 2, 3]
        E = [(1, 2), (2, 1), (3, 1)]
        G = MathGraph(V, E)

        self.assertTrue(exists_route(G, 1, 1))
        self.assertTrue(exists_route(G, 1, 2))
        self.assertTrue(exists_route(G, 2, 1))
        self.assertTrue(exists_route(G, 2, 2))
        self.assertTrue(exists_route(G, 3, 1))
        self.assertTrue(exists_route(G, 3, 2))
        self.assertFalse(exists_route(G, 1, 3))
        self.assertFalse(exists_route(G, 2, 3))
        self.assertFalse(exists_route(G, 3, 3))
Exemplo n.º 6
0
    def test_3(self):
        V = [1, 2, 3, 4, 5, 6]
        E = [(1, 2), (2, 3), (3, 4), (4, 2), (4, 5)]
        G = MathGraph(V, E)

        self.assertFalse(exists_route(G, 1, 6))
Exemplo n.º 7
0
    def test_2(self):
        V = [1, 2]
        E = [(1, 2), (2, 1)]
        graph = MathGraph(V, E)

        self.assertRaises(ValueError, build_order, graph)