本文整理汇总了Python中src.graph.Graph.dijkstra方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.dijkstra方法的具体用法?Python Graph.dijkstra怎么用?Python Graph.dijkstra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.graph.Graph
的用法示例。
在下文中一共展示了Graph.dijkstra方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dijkstra_complex
# 需要导入模块: from src.graph import Graph [as 别名]
# 或者: from src.graph.Graph import dijkstra [as 别名]
def test_dijkstra_complex(self):
graph = Graph('test/netfiles/test4.net.xml', False)
costs = {}
for edge in graph.edges:
costs[edge] = 1
graph.set_destination_and_costs('30668', costs)
self.assertEqual(graph.dijkstra('-31439', costs), ['-31439','-30057','-28887','28866','-23377','-22520','-21950','-17064','-16421','-15637','-3694','-3348','-158','144','-212','213','-370','420','-809','1807','-2481','2488','2556','-3837','3836','4158','4982','12338','-20947','-20171','20161','20824','-22781','-22135','22133','22780','27742','29467','30668'])
示例2: test_dijkstra_simple
# 需要导入模块: from src.graph import Graph [as 别名]
# 或者: from src.graph.Graph import dijkstra [as 别名]
def test_dijkstra_simple(self):
graph = Graph('test/netfiles/test1.net.xml', False)
costs = {}
for edge in graph.edges:
costs[edge] = 1
graph.set_destination_and_costs(graph.edges[-1], costs)
self.assertEqual(graph.dijkstra(graph.edges[1], costs), ['-25','5'])