예제 #1
0
def setup(max_outgoing, max_airports):
    graph = Graph()
    graph.init_with_data(False, max_outgoing, max_airports, silent=True)
    # select random start and finish airports
    src = random.choice(list(graph.airport_dict.values()))
    while len(src.outgoing_flights) == 0:
        src = random.choice(list(graph.airport_dict.values()))

    dest = random.choice(list(graph.airport_dict.values()))
    while dest.get_code() == src.get_code():
        dest = random.choice(list(graph.airport_dict.values()))

    return src, dest, graph
예제 #2
0
from load_data import LoadData
from models.graph import Graph

prelim = input("\"load\" or \"open\"\n")
graph = Graph()
max_outgoing = int(input("Enter max # of outgoing flights per airport: "))

if prelim == 'load':
    graph.init_with_data(True, max_outgoing, max_airports=4)
else:
    graph.init_with_data(False, max_outgoing, max_airports=4)

while True:
    try:
        src_code = input("Src Airport Code: ")

        src_airport = graph.get_airport(src_code.upper())
        src_airport.print_flights()

        dest_code = input("Dest Airport Code: ")

        dest_airport = graph.get_airport(dest_code.upper())
        dest_airport.print_flights()

        start_time = int(input('Start Time (as a seconds timestamp): '))

        from algorithm import FlightOptimizer, FlightNoptimizer

        print("\nBETTER")
        fo = FlightOptimizer(src_airport, dest_airport, start_time)
        fo.find_best_path(graph)