-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGraphTest.cpp
More file actions
53 lines (42 loc) · 1.33 KB
/
GraphTest.cpp
File metadata and controls
53 lines (42 loc) · 1.33 KB
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
#include <iostream>
#include <ctime>
#include "Graph.h"
#include "Dijkstra.h"
using namespace std;
int main(int argc, char* argv[])
{
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
system("chcp 65001");
#endif
const Graph G = [argc, argv]{
Graph G;
if (argc == 1) {
G.loadFromFile("Dijkstra.txt");
} else {
G.loadFromFile(argv[1]);
}
return G;
}();
const vertex::size_type startNode = 1;
const vertex::size_type finishNode = min(G.size()-1, vertex::size_type(9563));
time_t start = clock();
Dijkstra<vertex> dk(G);
auto v = dk.calcPath(startNode, finishNode);
time_t finish = clock();
cout << "Кратчайший путь: ";
for (auto x : v.first)
{
cout << x << " ";
}
cout << "\nДлина пути из " << startNode << " в " << finishNode << " равна " << v.second << "\n";
cout << "Time: " << double(finish - start) / CLOCKS_PER_SEC << " seconds\n";
/*G.saveToFile("graph.txt");
system("pause");
G.loadFromFile("graph.txt");
//G.printGraph();
system("graph.txt");*/
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
system("pause");
#endif
return 0;
}