Пример #1
0
 def because_we_calculate_the_most_cost_effective_path(self):
     self.path, self.cost = shortest_path(self.graph, self.vertexA, self.vertexD)
Пример #2
0
 def because_we_calculate_the_shortest_path_to_an_unreachable_vertex(self):
     self.path, self.cost = shortest_path(self.graph, self.vertexA, self.vertexD)
Пример #3
0
 def because_we_calculate_the_most_cost_effective_path(self):
     self.callback = lambda: shortest_path(self.graph, self.vertexA, self.vertexB)
Пример #4
0
print(
    "Total journey time for Buenos Aires -> Cape Town -> Casablanca is {}".format(
        total_path_cost_days(shipping_graph, [buenos_aires, cape_town, casablanca])
    )
)


"""
Find the shortest journey time for the following routes:

- Buenos Aires -> Liverpool

- New York -> New York
"""

_, journey = shortest_path(shipping_graph, buenos_aires, liverpool)
print("Shortest journey time for Buenos Aires -> Liverpool is {} days".format(journey))

_, journey = shortest_path(shipping_graph, new_york, new_york)
print("Shortest journey time for New York -> New York is {} days".format(journey))


"""
Find the number of routes from Liverpool to Liverpool with a maximum number of 3 stops.

Find the number of routes from Buenos Aires to Liverpool where exactly 4 stops are made.
"""

print(
    "The number of routes from Liverpool to Liverpool with a maximum number of 3 stops are {}".format(
        len(list(find_paths(shipping_graph, liverpool, liverpool, 3)))