예제 #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)
예제 #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)
예제 #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)
예제 #4
0
 def test_AddVertexFull(self):
     graph = SimpleGraph(2)
     graph.AddVertex(0)
     graph.AddVertex(1)
     result = graph.AddVertex(2)
     self.assertFalse(result)
예제 #5
0
 def test_BreadthFirstSearchSingleVertexWithoutEdge(self):
     graph = SimpleGraph(5)
     graph.AddVertex(0)
     result = graph.BreadthFirstSearch(0, 0)
     self.assertTrue(result == [], result)