示例#1
0
 def test_bfs(self):
     """ Tests that add_node properly adds nodes to adjecency list """
     # Uses graph in this article:
     # http://bit.ly/2ONjp55
     graph = Graph({
         'A': set(['B', 'C']),
         'B': set(['A', 'D', 'E']),
         'C': set(['A', 'F']),
         'D': set(['B']),
         'E': set(['B', 'F']),
         'F': set(['C', 'E'])
     })
     # self.assertSetEqual(['A', 'B', 'C', ''])
     path = graph.bfs('A')
     self.assertListEqual(['A', 'B', 'C', 'E', 'D', 'F'], path)
     pass