def get_graph(restaurants, movies, home, travel_mode = 'driving'):

    graph = []

    home = Node(home)
    
    #weight originally just set to the time of travel
    for movie in movies:
        show = Node(movie)
        home.add_edge(show, show.data.travel_from_home) #did we do this?
        
        for node in graph:
            #move to movie?
            if node.data.type != 'movie':
                travel = get_distance(node.data.lat, node.data.lng, movie.lat, movie.lng, travel_mode)
                node.add_edge(show,travel)
                show.add_edge(node, travel)

        graph.append(show)

    for restaurant in restaurants:
        eat = Node(restaurant)
        home.add_edge(eat, get_distance(home.data.lat, home.data.lng, restaurant.lat, restaurant.lng, travel_mode))

        for node in graph:
            if node.data.type != 'restaurant':
                travel = get_distance(node.data.lat, node.data.lng, restaurant.lat, restaurant.lng, travel_mode)
                node.add_edge(eat,travel)
                eat.add_edge(node, travel)

        graph.append(eat)

    return (home,graph)
Example #2
0
def get_graph(restaurants, movies, home, travel_mode = 'driving'):

    graph = []

    home = Node(home)
    
    #weight originally just set to the time of travel
    for movie in movies:
        show = Node(movie)
        home.add_edge(show, show.data.travel_from_home) #did we do this?
        
        for node in graph:
            #move to movie?
            if node.data.type != 'movie':
                travel = get_distance(node.data.lat, node.data.lng, movie.lat, movie.lng, travel_mode)
                node.add_edge(show,travel)
                show.add_edge(node, travel)

        graph.append(show)

    for restaurant in restaurants:
        eat = Node(restaurant)
        home.add_edge(eat, get_distance(home.data.lat, home.data.lng, restaurant.lat, restaurant.lng, travel_mode))

        for node in graph:
            if node.data.type != 'restaurant':
                travel = get_distance(node.data.lat, node.data.lng, restaurant.lat, restaurant.lng, travel_mode)
                node.add_edge(eat,travel)
                eat.add_edge(node, travel)

        graph.append(eat)

    return (home,graph)
def get_movie_objs(data_dict,
                   home,
                   user_start,
                   user_end,
                   travel_mode='driving'):

    movies = set([])

    theatre_count = 0

    for theatre in data_dict.keys():
        #if theatre_count < theatre_max:
        #   theatre_count += 1
        address = data_dict[theatre]['address']
        (lat, lng) = get_coordinates(address)
        travel_time = get_distance(home.lat, home.lng, lat, lng, travel_mode)
        if user_start + travel_time < user_end:
            for name in data_dict[theatre]['movies'].keys():
                run_time = data_dict[theatre]['movies'][name]['run_time']
                for time in data_dict[theatre]['movies'][name]['start_times']:
                    if run_time != None:
                        if time > user_start and time + run_time < user_end:
                            movie_obj = movie(name, time, run_time, theatre,
                                              lat, lng, travel_time)
                            movies.add(movie_obj)

    return movies
def get_movie_objs(data_dict, home, user_start, user_end, travel_mode = 'driving'):

    movies = set([])

    theatre_count = 0

    for theatre in data_dict.keys():
        #if theatre_count < theatre_max:
         #   theatre_count += 1
        address = data_dict[theatre]['address']
        (lat,lng) = get_coordinates(address)
        travel_time = get_distance(home.lat, home.lng,lat, lng, travel_mode)
        if user_start + travel_time < user_end:
            for name in data_dict[theatre]['movies'].keys():
                run_time = data_dict[theatre]['movies'][name]['run_time']
                for time in data_dict[theatre]['movies'][name]['start_times']:
                    if run_time != None:
                        if time > user_start and  time + run_time < user_end:
                            movie_obj = movie(name, time, run_time, theatre, lat, lng, travel_time)
                            movies.add(movie_obj)

    return movies