-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path150140715.cpp
84 lines (58 loc) · 2.05 KB
/
150140715.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* @author Tolga İnkaya
*/
#include "helper.hpp"
#include "hw2.hpp"
#include "test.hpp"
using namespace std;
using namespace gp;
using namespace sol;
int main(int argc, const char * argv[]) {
int source, destination, k_paths;
string test_file;
int number_of_node=0;
vector<int> index,c1;
string line;
std::ifstream infile(argv[1]);
test_file = argv[1];
std::string str;
std::vector<std::string> tokens;
std::vector<int> destinations;
// Number Of Vertices
getline(infile, str);
number_of_node = (int128_t)std::stoi(str);
getline(infile, str);
tokens = split(str, ' ');
destinations.push_back(std::stoi(tokens[0])+1);
destinations.push_back(std::stoi(tokens[1])+1);
destinations.push_back(std::stoi(tokens[2])+1);
destinations.push_back(std::stoi(tokens[3])+1);
while (getline(infile, line))
{
istringstream iss(line);
int a,b,c;
if (!(iss >> a >> b >> c )) { break; } // error
index.push_back(a+1);
index.push_back(b+1);
c1.push_back(c);
}
int AdjacencyMatrix[number_of_node+1][number_of_node+1];
for (int i = 0; i < number_of_node+1; i++)
for (int j = 0; j < number_of_node+1; j++)
{AdjacencyMatrix[i][j] = 1000000;
for (int k=0; k< index.size()/2;k++)
AdjacencyMatrix[index[2*k]][index[2*k+1]] = c1[k];
}
vector<vector<int> > adjacencymatrix;
for ( int i=0;i< sizeof (AdjacencyMatrix)/sizeof (AdjacencyMatrix[0]);i++)
{ vector<int> temp;
for (int j=0;j< sizeof (AdjacencyMatrix[0])/sizeof (AdjacencyMatrix[0][0]);j++)
temp.push_back(AdjacencyMatrix[i][j]);
adjacencymatrix.push_back(temp);
temp.clear(); }
// object to solve assignment
Solution assignment = Solution();
// returning appropriate shortest path
int minimumDistance = assignment.Assignment2Solver(destinations, number_of_node, adjacencymatrix, k_paths);
return 0;
}