-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.cpp
71 lines (52 loc) · 1.36 KB
/
main.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
#include <iostream>
#include <cstdlib>
#include <thread>
#include <vector>
#include <chrono>
#include "Prims.h"
#include "Node.h"
#include "Edge.h"
#include "Graph.h"
using namespace std;
// This variable will be extern-ed.
int number_of_nodes;
void printGraph(vector <int>);
int main (void) {
// We need to take the input here.
cin >> number_of_nodes;
Graph *g = Graph::getInstance();
vector <int> graph;
graph.resize(number_of_nodes * number_of_nodes);
int temp;
for (int i = 0; i < number_of_nodes * number_of_nodes; i++) {
cin >> temp;
graph[i] = temp;
}
printGraph(graph);
// Creating the graph.
g -> createGraph(number_of_nodes, graph);
g -> printGraph();
// Distributing the graph.
g -> distributeGraph();
// Run all the nodes.
g -> runNodes();
// Wake one node up.
g -> wakeOneNodeUp();
// Sleep for a while maybe?
chrono::milliseconds duration(2000);
// this_thread::sleep_for(duration);
Prims *p = new Prims(graph);
p -> findMst();
p -> printMst();
delete g;
return 0;
}
void printGraph(vector<int> v) {
for (int i = 0; i < number_of_nodes; i++) {
for (int j = 0; j < number_of_nodes; j++) {
cout << v[i*number_of_nodes + j] << " ";
}
cout << endl;
}
cout << endl;
}