Ejemplo n.º 1
0
 def test_AddVertex(self):
     graph = SimpleGraph(5)
     graph.AddVertex(0)
     result = graph.AddVertex(1)
     self.assertTrue(result)
     self.assertTrue(isinstance(graph.vertex[1], Vertex))
     self.assertTrue(graph.vertex[1].Value == 1)
     self.checkVertexAdjacency(graph, 1, [0] * 5)
Ejemplo n.º 2
0
 def test_AddVertexEmpty(self):
     graph = SimpleGraph(5)
     result = graph.AddVertex(0)
     self.assertTrue(result)
     self.assertTrue(isinstance(graph.vertex[0], Vertex))
     self.assertTrue(graph.vertex[0].Value == 0)
     self.checkVertexAdjacency(graph, 0, [0] * 5)
Ejemplo n.º 3
0
 def test_DepthFirstSearchSingleVertexWithEdge(self):
     graph = SimpleGraph(5)
     graph.AddVertex(0)
     graph.AddEdge(0, 0)
     result = graph.DepthFirstSearch(0, 0)
     self.assertTrue(result == [graph.vertex[0], graph.vertex[0]], result)
Ejemplo n.º 4
0
 def test_AddVertexFull(self):
     graph = SimpleGraph(2)
     graph.AddVertex(0)
     graph.AddVertex(1)
     result = graph.AddVertex(2)
     self.assertFalse(result)
Ejemplo n.º 5
0
 def test_BreadthFirstSearchSingleVertexWithoutEdge(self):
     graph = SimpleGraph(5)
     graph.AddVertex(0)
     result = graph.BreadthFirstSearch(0, 0)
     self.assertTrue(result == [], result)