-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
41 lines (38 loc) · 1.83 KB
/
main.cpp
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
#include <iostream>
#include <vector>
#include "utilities.h"
#include "Graph.h"
using namespace std;
int main() {
//Graph *g = buildGraphfromDatafile("station_route.txt"); // build a graph of the London Underground tube routes
//vector<string> stationNames = readStationNames("station_names.txt"); // read the station names
//cout << g->are_connected(313, 4) << endl;
try {
Graph *g = buildGraphfromDatafile("station_route.txt"); // build a graph of the London Underground tube routes
vector<string> stationNames = readStationNames("station_names.txt"); // read the station names
//g->print_matrix(10,32);
{
int from = 313; // station id=313 represents Whitechapel
int destination = 55; // station id=55 represents Charing_Cross
cout << "Going from " << stationNames[from] << " to " << stationNames[destination] << "?" << endl;
vector<int> stations = g->getPath(from, destination);
cout << "There are " << stations.size() << " stations in between: " << endl;
for (unsigned int i = 0; i < stations.size(); i++)
cout << stationNames[stations[i]] << endl;
// One possible path: Whitechapel -> Aldgate_East -> Liverpool_Street -> Bank -> Monument -> Cannon_Street -> Mansion_House -> Blackfriars -> Temple -> Embankment -> Charing_Cross
}
{
// another example
int from = 15; // station id=15 represents Barbican
int destination = 137; // station id=137 represents Holborn
cout << "Going from " << stationNames[from] << " to " << stationNames[destination] << "?" << endl;
vector<int> stations = g->getPath(from, destination);
cout << "There are " << stations.size() << " stations in between: " << endl;
for (unsigned int i = 0; i < stations.size(); i++)
cout << stationNames[stations[i]] << endl;
}
}
catch (exception &e) {
cout << e.what() << endl;
}
}