def complex_wgraph(): """Fixture to seet up a complex weighted-graph for use in testing.""" from weighted_graph import WGraph wg = WGraph() for edge in COMPLEX_WGRAPH: wg.add_edge(edge[0], edge[1], edge[2]) return wg
def basic_wgraph(): """Fixture to seet up a basic weighted-graph for use in testing.""" from weighted_graph import WGraph wg = WGraph() for edge in BASIC_WGRAPH: wg.add_edge(edge[0], edge[1], edge[2]) return wg
def simple_wgraph(): """Fixture to seet up a simple weighted-graph for use in testing.""" from weighted_graph import WGraph wg = WGraph() for edge in SIMPLE_WGRAPH: wg.add_edge(edge[0], edge[1], edge[2]) return wg
def build_graph_with_data(): """Return a weighted graph with airport data.""" airports = parse_airport_data() air_graph = WGraph() for city, city_data in airports.items(): city_1 = city neighbors = city_data["neighbors"] for neighbor in neighbors: try: dist_between = calculate_distance( city_data["lat_long"], airports[neighbor]["lat_long"]) except KeyError: continue air_graph.add_edge(city_1, neighbor, dist_between) return air_graph
def complex_traversal_graph(): from weighted_graph import WGraph ctg = WGraph() for node in COMPLEX_TRAVERSAL_NODES: ctg.add_node(node) for edge in COMPLEX_TRAVERSAL_EDGES: ctg.add_edge(edge[0], edge[1], edge[2]) return ctg
def med_cyclical_graph(): from weighted_graph import WGraph mcg = WGraph() for node in MED_CYCLICAL_NODES: mcg.add_node(node) for edge in MED_CYCLICAL_EDGES: mcg.add_edge(edge[0], edge[1], edge[2]) return mcg
def cyclical_graph(): from weighted_graph import WGraph cg = WGraph() for node in CYCLICAL_NODES: cg.add_node(node) for edge in CYCLICAL_EDGES: cg.add_edge(edge[0], edge[1], edge[2]) return cg
def traversal_graph(): from weighted_graph import WGraph tg = WGraph() for node in TRAVERSAL_NODES: tg.add_node(node) for edge in TRAVERSAL_EDGES: tg.add_edge(edge[0], edge[1], edge[2]) return tg
def circle_with_tail_graph(): from weighted_graph import WGraph cwtg = WGraph() for node in CIRCLE_WITH_TAIL_NODES: cwtg.add_node(node) for edge in CIRCLE_WITH_TAIL_EDGES: cwtg.add_edge(edge[0], edge[1], edge[2]) return cwtg
def graph_edges(): from weighted_graph import WGraph g = WGraph() for node in TEST_NODES: g.add_node(node) for edge in TEST_EDGES: g.add_edge(edge[0], edge[1], edge[2]) return g
def graph_nodes(): from weighted_graph import WGraph g = WGraph() for node in TEST_NODES: g.add_node(node) return g
def empty_graph(): """Create an empty graph.""" from weighted_graph import WGraph return WGraph()
def simple_wgraph(): from weighted_graph import WGraph wg = WGraph() for edge in SIMPLE_WGRAPH: wg.add_edge(edge[0], edge[1], edge[2]) return wg