def test_DepthFirstSearchThreeVertexWithEdge(self): graph = SimpleGraph(5) self.addVertexes(graph, [0, 1, 2]) graph.AddEdge(0, 1) graph.AddEdge(0, 2) result = graph.DepthFirstSearch(0, 2) self.assertTrue(result == [graph.vertex[0], graph.vertex[2]], result)
def test_DepthFirstSearchTwoVertexWithoutEdge(self): graph = SimpleGraph(5) self.addVertexes(graph, [0, 1]) result = graph.DepthFirstSearch(0, 1) self.assertTrue(result == [], result)
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)