-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputGenerator.cpp
More file actions
75 lines (69 loc) · 1.82 KB
/
inputGenerator.cpp
File metadata and controls
75 lines (69 loc) · 1.82 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <fstream>
#include <map>
#include <random>
#include <set>
#include <iostream>
using namespace std;
void generateEdges(map<int, set<int> >& edges, int curr, int max, int min, int& total){
random_device rd;
mt19937 gen(rd());
int temp;
uniform_int_distribution<> distribution(min, max);
uniform_int_distribution<> dist(10,20);
if(curr != 5000){
temp = curr + 2;
edges[curr].insert(temp);
}
if(curr != 1){
temp = curr;
edges[curr].insert(temp);
}
int maxSize = dist(gen);
total += maxSize;
while(edges[curr].size() < maxSize){
temp = distribution(gen);
if(temp != curr + 1){
edges[curr].insert(temp);
}
}
}
void toFile(map<int, set<int> >& edges){
ofstream fout ("input2.txt");
fout << 5000 << endl;
for(int i = 0; i < 4999; i++){
fout << edges[i].size();
for(auto it = edges[i].begin(); it != edges[i].end(); ++it){
fout << " " << *it;
}
fout << endl;
}
fout << edges[5000].size();
for(auto it = edges[5000].begin(); it != edges[5000].end(); it++){
fout << " " << *it;
}
}
int main(){
map<int, set<int> > edges;
int size = 5000;
int total = 2;
edges[1].insert(5000);
edges[5000].insert(1);
for(int i = 1; i < 1001; i++){
generateEdges(edges, i, 1000, 1, total);
}
for(int i = 1001; i < 2001; i++){
generateEdges(edges, i, 2000, 1001, total);
}
for(int i = 2001; i < 3001; i++){
generateEdges(edges, i, 3000, 2001, total);
}
for(int i = 3001; i < 4001; i++){
generateEdges(edges, i, 4000, 3001, total);
}
for(int i = 4001; i < 5001; i++){
generateEdges(edges, i, 5000, 4001, total);
}
toFile(edges);
cout << total << endl;
return 0;
}