예제 #1
0
 def test_eulerian_array_open(self):
     """Test eulerian array open."""
     graph = Graph(True, False)
     a = Vertex(0)
     b = Vertex(1)
     c = Vertex(2)
     d = Vertex(3)
     e = Vertex(4)
     f = Vertex(5)
     graph.add_vertex(a)
     graph.add_vertex(b)
     graph.add_vertex(c)
     graph.add_vertex(d)
     graph.add_vertex(e)
     graph.add_vertex(f)
     graph.create_array()
     graph.add_edge(a, a)
     graph.add_edge(b, b)
     graph.add_edge(c, c)
     graph.add_edge(d, d)
     graph.add_edge(a, b)
     graph.add_edge(a, c)
     graph.add_edge(d, e)
     graph.add_edge(d, f)
     graph.add_edge(e, f)
     self.assertEqual(graph.eulerian(), "Eulerian open", msg='Teste 2')
예제 #2
0
 def test_search_vertex_array_not_directed(self):
     """Test search vertex array not directed."""
     graph = Graph(True, False)
     a = Vertex(0)
     b = Vertex(1)
     graph.add_vertex(a)
     graph.add_vertex(b)
     graph.create_array()
     graph.add_edge(a, a)
     graph.add_edge(a, b)
     self.assertEqual(graph.search_vertex(a), [0, 1], msg='Teste 1')
예제 #3
0
 def test_add_vertex_array_directed(self):
     """Test add vertex array directed."""
     graph = Graph(True, True)
     a = Vertex(0)
     b = Vertex(1)
     graph.add_vertex(a)
     graph.add_vertex(b)
     graph.create_array()
     graph.add_edge(a, a)
     graph.add_edge(b, b)
     self.assertEqual(graph.add_edge(a, b), True, msg='Teste 2')
예제 #4
0
 def test_eulerian_array(self):
     """Test eulerian array."""
     graph = Graph(True, False)
     a = Vertex(0)
     b = Vertex(1)
     graph.add_vertex(a)
     graph.add_vertex(b)
     graph.create_array()
     graph.add_edge(a, a)
     graph.add_edge(b, b)
     graph.add_edge(a, b)
     self.assertEqual(graph.eulerian(), "Is Eulerian", msg='Teste 1')
예제 #5
0
    def test_transitive_closing_array_directed(self):
        """Test."""
        graph = Graph(True, True)  # matriz direcionada
        a = Vertex(0)
        b = Vertex(1)
        c = Vertex(2)
        d = Vertex(3)

        graph.add_vertex(a)
        graph.add_vertex(b)
        graph.add_vertex(c)
        graph.add_vertex(d)

        graph.create_array()

        graph.add_edge(a, b)
        graph.add_edge(b, c)
        graph.add_edge(c, d)

        self.assertEqual(graph.transitive_closing(), True, msg='Teste 1')
예제 #6
0
    def test_strongly_connected_component_arry_directed(self):
        graph = Graph(True, True)  # matriz direcionada

        a = Vertex(0)
        b = Vertex(1)
        c = Vertex(2)
        d = Vertex(3)

        graph.add_vertex(a)
        graph.add_vertex(b)
        graph.add_vertex(c)
        graph.add_vertex(d)

        graph.create_array()

        graph.add_edge(a, b)
        graph.add_edge(b, a)
        graph.add_edge(b, c)
        graph.add_edge(c, d)
        graph.add_edge(d, c)

        self.assertEqual(graph.SCC(), True, msg='Teste 1')
예제 #7
0
    def test_algorithm_warshall_array_directed(self):
        """Test."""
        graph = Graph(True, True)  # matriz direcionada

        a = Vertex(0)
        b = Vertex(1)
        c = Vertex(2)
        d = Vertex(3)
        graph.add_vertex(a)
        graph.add_vertex(b)
        graph.add_vertex(c)
        graph.add_vertex(d)

        graph.create_array()

        graph.add_edge(a, d)
        graph.add_edge(b, a)
        graph.add_edge(b, c)
        graph.add_edge(c, a)
        graph.add_edge(c, d)
        graph.add_edge(d, c)

        self.assertEqual(graph.algorithm_warshall(), True, msg='Test 1')