本文整理汇总了Python中apgl.graph.DictGraph.DictGraph.breadthFirstSearch方法的典型用法代码示例。如果您正苦于以下问题:Python DictGraph.breadthFirstSearch方法的具体用法?Python DictGraph.breadthFirstSearch怎么用?Python DictGraph.breadthFirstSearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apgl.graph.DictGraph.DictGraph
的用法示例。
在下文中一共展示了DictGraph.breadthFirstSearch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testBreadthFirstSearch
# 需要导入模块: from apgl.graph.DictGraph import DictGraph [as 别名]
# 或者: from apgl.graph.DictGraph.DictGraph import breadthFirstSearch [as 别名]
def testBreadthFirstSearch(self):
graph = DictGraph()
graph.addEdge(0, 1)
graph.addEdge(0, 7)
graph.addEdge(7, 8)
graph.addEdge(7, 9)
graph.addEdge(1, 2)
graph.addEdge(1, 3)
graph.addEdge(2, 6)
graph.addEdge(4, 5)
self.assertEquals(graph.breadthFirstSearch(0), [0,1, 7,2,3,8,9,6])
self.assertEquals(graph.breadthFirstSearch(1), [1,0,2,3,7,6,8,9])
self.assertEquals(graph.breadthFirstSearch(6), [6, 2,1,0,3,7,8,9])
self.assertEquals(graph.breadthFirstSearch(4), [4, 5])
self.assertEquals(graph.breadthFirstSearch(5), [5, 4])
self.assertEquals(graph.breadthFirstSearch(7), [7, 0, 8, 9, 1, 2, 3, 6])