-
Notifications
You must be signed in to change notification settings - Fork 0
/
printgraph.cc
59 lines (43 loc) · 1.28 KB
/
printgraph.cc
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
/*
g++ -o printgraph.exe printgraph.cc
*/
#include <climits>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <queue>
#include <string>
// #define NUM_V 4
#define NUM_V 7
int main(int argc, char **argv) {
// Read file
std::ifstream input_file(argv[1]);
std::string line;
std::string cell;
std::getline(input_file, line);
int num_v = std::stoi(line);
std::vector<
std::vector<int>> original_graph(num_v);
for (int y=0; y < num_v; y++) {
std::getline(input_file, line);
std::stringstream line_stream(line);
std::vector<int> curr_vector(num_v);
for (int x=0; x < num_v; x++) {
std::getline(line_stream, cell, ',');
curr_vector[x] = std::stoi(cell);
}
original_graph[y] = curr_vector;
}
input_file.close();
// Printing next graph level
std::cout << "\nPrinting the next level of graph. num_v=" << num_v;
for (int row=0; row < original_graph.size(); row++) {
std::cout << "\n[";
for (int col=0; col < original_graph[0].size(); col++) {
std::cout << original_graph[row][col] << ", ";
}
std::cout << "]";
}
return 0;
}