コード例 #1
0
ファイル: test_shortest_path.py プロジェクト: ekiourk/hermes
 def because_we_calculate_the_most_cost_effective_path(self):
     self.path, self.cost = shortest_path(self.graph, self.vertexA, self.vertexD)
コード例 #2
0
ファイル: test_shortest_path.py プロジェクト: ekiourk/hermes
 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
ファイル: test_shortest_path.py プロジェクト: ekiourk/hermes
 def because_we_calculate_the_most_cost_effective_path(self):
     self.callback = lambda: shortest_path(self.graph, self.vertexA, self.vertexB)
コード例 #4
0
ファイル: shipping_operator.py プロジェクト: ekiourk/hermes
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)))