Beispiel #1
0
 def because_we_want_all_available_paths_from_A_to_B(self):
     self.paths = list(find_paths(self.graph, self.vertexA, self.vertexA, 5))
Beispiel #2
0
 def because_we_want_all_available_paths_from_A_to_B_and_those_smaller_than_2(self):
     self.paths = list(find_paths(self.graph, self.vertexA, self.vertexD, 5))
     self.paths_less_than_cutoff = list(find_paths(self.graph, self.vertexA, self.vertexD, 2))
     self.paths_equal_2_size = list(find_paths_equal_to_size(self.graph, self.vertexA, self.vertexD, 2))
     self.paths_equal_3_size = list(find_paths_equal_to_size(self.graph, self.vertexA, self.vertexD, 3))
     self.paths_equal_4_size = list(find_paths_equal_to_size(self.graph, self.vertexA, self.vertexD, 4))
Beispiel #3
0
_, 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)))
    )
)

print(
    "The number of routes from Buenos Aires to Liverpool where exactly 4 stops are made are {}".format(
        len(list(find_paths_equal_to_size(shipping_graph, buenos_aires, liverpool, 4)))
    )
)

"""
Find the number of routes from Liverpool to Liverpool where the journey time is less than or equal to 25 days.
"""

print(
    "The number of routes from Liverpool to Liverpool where the journey time is less than or equal to 25 days are {}".format(