-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
56 lines (49 loc) · 1.03 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <string>
#include "graph.h"
#include <limits.h>
using namespace std;
// Part 1: Find tickets for an airline passenger
void P5_part1()
{
string cty1,cty2;
int arp_n, rts_n;
cin >> arp_n >> rts_n;
Graph *g = new Graph(arp_n, rts_n); //constr. reads in the paths
//g->printGraph();
cin >> cty1;
while(cty1 != "END") // Find tickets until END appears
{
cin >> cty2;
g->find_ticket(cty1, cty2);
cin >> cty1;
}
}
// Part 2: Perform an eulerian tour of the graph.
void P5_part2()
{
string cty1,cty2;
int arp_n, rts_n;
cin >> arp_n >> rts_n;
Graph *g = new Graph(arp_n, rts_n); //constr. reads in the paths
//g->printGraph();
string MST_rt;
cin >> MST_rt;
string* mst = g->prims(MST_rt);
/*cout << "MST for root " << MST_rt << ": ";
for(int i = 0; i < arp_n; i++)
cout << parent[i] << " " ;
cout << endl << endl;
cout << "tour with same root: "<< endl;*/
g->eulerian_tour(MST_rt, mst);
}
int main()
{
int cmd;
cin >> cmd;
if(cmd == 1)
P5_part1();
else if(cmd == 2)
P5_part2();
return 0;
}