-
Notifications
You must be signed in to change notification settings - Fork 0
/
T2_2.cpp
54 lines (51 loc) · 969 Bytes
/
T2_2.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
#include "Digraph.h"
int main() {
Digraph<char> d;
d.read(cin);
cout << "The Digraph's ";
d.display(cout);
cout << endl;
int start, destination;
char response;
do {
cout << "Start: ";
cin >> start;
cout << "Destination: ";
cin >>destination;
vector<int> path = d.shortestPath(start, destination);
if (!path.empty()) {
cout << "Shortest path is:\n";
for (int k = path.size() - 1; k > 0; --k) {
cout << setw(3) << path[k] << " " << d.data(path[k]) << endl;
cout << " |\n"
<< " v\n";
}
cout << setw(3) << destination << " " << d.data(destination) << endl;
}
cout << "\nMore (Y or N)?";
cin >> response;
} while (response == 'y' || response == 'Y');
return 0;
}
/*
6
A 3
1 4
2 12
4 4
B 3
0 2
2 6
3 8
C 2
1 6
3 14
D 2
0 12
4 4
E 1
3 10
F 2
4 6
3 20
*/