本文整理汇总了Python中src.graph.Graph.set_destination_and_costs方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.set_destination_and_costs方法的具体用法?Python Graph.set_destination_and_costs怎么用?Python Graph.set_destination_and_costs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类src.graph.Graph
的用法示例。
在下文中一共展示了Graph.set_destination_and_costs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dijkstra_simple
# 需要导入模块: from src.graph import Graph [as 别名]
# 或者: from src.graph.Graph import set_destination_and_costs [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'])
示例2: test_dijkstra_complex
# 需要导入模块: from src.graph import Graph [as 别名]
# 或者: from src.graph.Graph import set_destination_and_costs [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'])
示例3: test_is_optimalization_needed
# 需要导入模块: from src.graph import Graph [as 别名]
# 或者: from src.graph.Graph import set_destination_and_costs [as 别名]
def test_is_optimalization_needed(self):
graph = Graph('test/netfiles/test1.net.xml', False)
graph.edges = ['1', '2', '3', '4', '5']
graph.set_destination_and_costs('5', {'1':10, '2':10, '3':10, '4':10, '5':10})
self.assertTrue(graph.is_optimalization_needed(['1','3','5'], {'1':10, '2':10, '3':12, '4':10, '5':10}, 0.1))
self.assertTrue(graph.is_optimalization_needed(['1','3','5'], {'1':10, '2':8, '3':10, '4':10, '5':10}, 0.1))
self.assertFalse(graph.is_optimalization_needed(['1','3','5'], {'1':10, '2':10, '3':8, '4':10, '5':10}, 0.1))
self.assertFalse(graph.is_optimalization_needed(['1','3','5'], {'1':10, '2':12, '3':10, '4':10, '5':10}, 0.1))