Пример #1
0
 def test_BreadthFirstSearchThreeVertexWithTwoEdges(self):
     graph = SimpleGraph(5)
     self.addVertexes(graph, [0, 1, 2])
     graph.AddEdge(0, 1)
     graph.AddEdge(1, 2)
     result = graph.BreadthFirstSearch(0, 2)
     self.assertTrue(result == [graph.vertex[0], graph.vertex[1], graph.vertex[2]], result)
Пример #2
0
 def test_BreadthFirstSearchWithDifferentPaths(self):
     graph = SimpleGraph(5)
     self.addVertexes(graph, [0, 1, 2, 3, 4])
     graph.AddEdge(0, 1)
     graph.AddEdge(1, 2)
     graph.AddEdge(2, 3)
     graph.AddEdge(3, 4)
     graph.AddEdge(4, 0)
     result = graph.BreadthFirstSearch(0, 2)
     self.assertTrue(result == [graph.vertex[0], graph.vertex[1], graph.vertex[2]], result)
Пример #3
0
 def test_BreadthFirstSearchThreeVertexWithoutEdge(self):
     graph = SimpleGraph(5)
     self.addVertexes(graph, [0, 1, 2])
     graph.AddEdge(0, 1)
     result = graph.BreadthFirstSearch(0, 2)
     self.assertTrue(result == [], result)
Пример #4
0
 def test_BreadthFirstSearchTwoVertexWithEdge(self):
     graph = SimpleGraph(5)
     self.addVertexes(graph, [0, 1])
     graph.AddEdge(0, 1)
     result = graph.BreadthFirstSearch(0, 1)
     self.assertTrue(result == [graph.vertex[0], graph.vertex[1]], result)
Пример #5
0
 def test_BreadthFirstSearchTwoVertexWithoutEdge(self):
     graph = SimpleGraph(5)
     self.addVertexes(graph, [0, 1])
     result = graph.BreadthFirstSearch(0, 1)
     self.assertTrue(result == [], result)
Пример #6
0
 def test_BreadthFirstSearchSingleVertexWithEdge(self):
     graph = SimpleGraph(5)
     graph.AddVertex(0)
     graph.AddEdge(0, 0)
     result = graph.BreadthFirstSearch(0, 0)
     self.assertTrue(result == [graph.vertex[0]], result)