def test_bfs_search_invalid_start_node(self): b_graph = Graph({'a': ['c'], 'c': ['d']}) bfs_result = bfs_search(b_graph, 'b', 'a') self.assertEqual(bfs_result, [])
def test_bfs_search_single_node(self): bfs_result = bfs_search(self.single_graph, 'a', 'a') self.assertEqual(bfs_result, ['a'])
def test_bfs_search_invalid_target_node(self): a_graph = Graph({'a': ['b'], 'b': []}) bfs_result = bfs_search(a_graph, 'a', 'c') self.assertEqual(bfs_result, [])
def test_bfs_search_two_nodes(self): two_nodes = Graph({'a': ['b'], 'b': []}) bfs_result = bfs_search(two_nodes, 'a', 'b') self.assertEqual(bfs_result, ['a', 'b'])
def test_bfs_search_not_graph(self): with self.assertRaises(TypeError): bfs_search('hello', 'world', '!')
def test_bfs_search_unconnected_graph(self): unconn_graph = Graph({'a': ['b', 'c'], 'b': ['d'], 'c': ['d'], 'e': ['f']}) bfs_result = bfs_search(unconn_graph, 'a', 'f') self.assertEqual(bfs_result, [])
def test_bfs_search_empty_graph(self): bfs_result = bfs_search(self.empty_graph, 'a', 'b') self.assertEqual(bfs_result, [])
def test_bfs1(self): print (graph_functions.bfs_search(self.myGraph, 'Node4', 'Node1')).__str__() print (graph_functions.bfs_search(self.myGraph, 'Node4', 'Node4')).__str__() print (graph_functions.bfs_search(self.myGraph, 'Node4', 'Node2')).__str__()