-
Notifications
You must be signed in to change notification settings - Fork 1
/
RouteGraph.h
89 lines (69 loc) · 2.35 KB
/
RouteGraph.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#pragma once
/* needed std structures */
#include <string>
#include <unordered_map>
#include <queue>
/* external structures and functions */
#include "graph.h"
#include "AirportList.hpp"
#include "Utility.h"
/* shorthand imports */
using std::string;
using std::unordered_map;
using std::queue;
using std::pair;
/* helpful typdefs */
typedef pair<string, string> Route;
typedef pair<float, float> Location;
typedef pair<Route, pair<Location, Location>> RouteDistance;
/**
* Class to store information about the airport routes
* Supports BFS and Djikstra's Algorithm
*/
class RouteGraph {
public:
/**
* Empty constructor to supress errors
*/
RouteGraph();
/**
* Default constructor to create a RouteGraph
* @param fileName : the name of the file containing the routes
* @param airportList : object containing airport information
*/
RouteGraph(string fileName, AirportList airportList);
/**
* Finds all of the routes in the data
* @return a vector of objects representing a route
*/
vector<RouteDistance> getAllRoutes();
/* --------------- getters --------------- */
int getNumAirports();
int getNumConnections();
Graph getGraph();
private:
/**
* Helper function to parse the data
* Initializes the graph by creating a parsed Route object
* @param fileName : the name of the file containing the routes
*/
void parseRoutes(string fileName);
/**
* Parses single entry of the data table
* @param entry : a single entry of the data table
* @return object representing the route
*/
Route parseEntry(string entry);
/**
* Helper BFS function that uses a given vertex
* @param vertex : The current vertex
* @param routes : A list of routes
*/
void BFS(Vertex vertex, vector<RouteDistance>& routes);
/* initialize graph object */
Graph graph_ = Graph(true, true);
/* initialize map for tracking visits */
unordered_map<string, bool> visitedMap_ = unordered_map<string, bool>();
/* initialize map for storing airport locations */
unordered_map<string, Location> airportLocations_ = unordered_map<string, Location>();
};