本文整理汇总了Python中map.Map.append方法的典型用法代码示例。如果您正苦于以下问题:Python Map.append方法的具体用法?Python Map.append怎么用?Python Map.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map.Map
的用法示例。
在下文中一共展示了Map.append方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_all_trips_3
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import append [as 别名]
def test_all_trips_3(self):
map = Map(1, 2, 3)
map.append(1, 3, 1)
map.append(3, 1, 1)
accept_func = lambda step, distance: True
trim_func = lambda step, distance: step > 5
self.assertEqual(map.all_trips(1, 3, accept_func, trim_func), 3)
示例2: test_sum_distance
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import append [as 别名]
def test_sum_distance(self):
map = Map(1, 2, 3)
map.append(1, 2, 1)
map.append(2, 3, 2)
map.append(3, 1, 4)
self.assertEqual(map.sum_distance(1, 2), 1)
self.assertEqual(map.sum_distance(1, 2, 3), 3)
self.assertEqual(map.sum_distance(1, 2, 3, 1), 7)
self.assertEqual(map.sum_distance(2, 1), 'NO SUCH ROUTE')
示例3: test_distance
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import append [as 别名]
def test_distance(self):
map = Map(1, 2, 3)
map.append(1, 2, 3)
map.append(1, 3, 3)
map.append(3, 2, 4)
self.assertEqual(map.distance(1, 2), 3)
self.assertEqual(map.distance(1, 3), 3)
self.assertEqual(map.distance(3, 2), 4)
self.assertIsNone(map.distance(2, 1))
示例4: test_all_trips_4
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import append [as 别名]
def test_all_trips_4(self):
map = Map(1, 2, 3)
map.append(1, 3, 10)
map.append(3, 1, 1)
accept_func = lambda step, distance: distance <= 12
trim_func = lambda step, distance: distance > 12
self.assertEqual(map.all_trips(1, 3, accept_func, trim_func), 1)
accept_func = lambda step, distance: distance <= 21
trim_func = lambda step, distance: distance > 21
self.assertEqual(map.all_trips(1, 3, accept_func, trim_func), 2)
示例5: input
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import append [as 别名]
def input(graph):
node_list = set()
edge_list = []
for i in graph:
node_list.add(i[0])
node_list.add(i[1])
edge_list.append([i[0], i[1], int(i[2:])])
map = Map(*node_list)
for i in edge_list:
map.append(*i)
return map
示例6: test_append
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import append [as 别名]
def test_append(self):
map = Map(1, 2, 3)
map.append(1, 2, 3)
map.append(1, 3, 3)
map.append(3, 2, 4)
self.assertEqual(map.node_list, (1, 2, 3))
self.assertEqual(map.map, {1: {1: None, 2: 3, 3: 3}, 2: {1: None, 2: None, 3: None}, 3: {1: None, 2: 4, 3: None}})
with self.assertRaises(AssertionError):
map.append(2, 3, 0)
with self.assertRaises(AssertionError):
map.append(4, 3, 1)
示例7: test_all_trips_1
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import append [as 别名]
def test_all_trips_1(self):
map = Map(1, 2, 3)
map.append(1, 3, 100)
accept_func = lambda step, distance: True
trim_func = lambda step, distance: False
self.assertEqual(map.all_trips(1, 3, accept_func, trim_func), 1)
示例8: test_shortest_route_2
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import append [as 别名]
def test_shortest_route_2(self):
map = Map(1, 2, 3)
map.append(1, 3, 100)
self.assertEqual(map.shortest_route(1, 3), 100)