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)
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)
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)
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)
def test_BreadthFirstSearchTwoVertexWithoutEdge(self): graph = SimpleGraph(5) self.addVertexes(graph, [0, 1]) result = graph.BreadthFirstSearch(0, 1) self.assertTrue(result == [], result)
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)