-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgennet.cpp
More file actions
55 lines (50 loc) · 1010 Bytes
/
gennet.cpp
File metadata and controls
55 lines (50 loc) · 1010 Bytes
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
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
int main(int argc, char** argv)
{
srand(time(0));
int n = atoi(argv[1]);
int k = atoi(argv[2]);
int cc = 1;
int i,j;
cout<<n<<" "<<k<<endl;
vector<string> nodes;
for(i=0; i<n; i++)
{
std::ostringstream oss;
oss << i;
nodes.push_back(string("node_") + oss.str());
}
for(i=0; i<n; i++)
cout<<nodes[i]<<endl;
for(i=0; i<n; i++)
{
// select 3 random nodes;
int ni1 = rand()%n;
int ni2 = rand()%n;
int ni3 = rand()%n;
while (ni1==ni2 || ni1==ni3 || ni2==ni3)
{
ni1 = rand()%n;
ni2 = rand()%n;
ni3 = rand()%n;
}
int ii, jj, ll;
for(ii=0; ii<=k; ii++)
{
for(jj=0; jj<=k; jj++)
{
for(ll=0; ll<=k; ll++)
{
int rv = rand()%(k+1);
cout<<nodes[i]<<" "<<rv<<" "<<nodes[ni1]<<" "<<ii<<" "<<nodes[ni2]<<" "<<jj<<" "<<nodes[ni3]<<" "<<ll<<endl;
}
}
}
}
return 0;
}