-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathmain_Paths.cpp.in
43 lines (39 loc) · 1.01 KB
/
main_Paths.cpp.in
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
/******************************************************************************
* % ./DepthFirstPaths tinyCG.txt 0
* 0 to 0: 0
* 0 to 1: 0-2-1
* 0 to 2: 0-2
* 0 to 3: 0-2-3
* 0 to 4: 0-2-3-4
* 0 to 5: 0-2-3-5
*
* % ./BreadthFirstPaths tinyCG.txt 0
* 0 to 0: 0
* 0 to 1: 0-1
* 0 to 2: 0-2
* 0 to 3: 0-2-3
* 0 to 4: 0-2-4
* 0 to 5: 0-5
*
******************************************************************************/
#include <fstream>
#include <iostream>
#include <string>
#include "@[email protected]"
int main(int argc, char *argv[]) {
std::ifstream in(argv[1]);
Graph G(in);
int s = std::stoi(argv[2]);
@PATHS_SEARCHER@ search(G, s);
for (int v = 0; v < G.V(); ++v) {
std::cout << s << " to " << v << ": ";
if (search.hasPathTo(v)) {
for (int x: search.pathTo(v)) {
if (x == s) std::cout << x;
else std::cout << "-" << x;
}
}
std::cout << std::endl;
}
return 0;
}