-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph.cpp
49 lines (37 loc) · 1.04 KB
/
graph.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
#include <iostream>
#include <cstdlib>
#include<fstream>
#include <stdlib.h>
using namespace std;
int random (int, int);
int main(){
ofstream ofile;
ofile.open ("oneM.dat");
int n = 1000000;
int edges, head, distance;
// for(int i = 0; i < n; i++){
// edges = random(0, 5);
// for(int j = 0; j < edges; j++){
// do{
// head = random(0, n-1);
// }while(i == head);
// distance = random(1, 5);
// // printf("%d %d %d\n", i, head, distance);
// ofile << i << " " << head << " " << distance << endl;
// }
// }
ofile << n << endl;
for( int i = 0; i < n-1; i++){
ofile << i << " " << i+1 << " " << 1 << endl;
if(i%1000000 == 0){
cout << (float)i/n * 100 << "%\r";
}
// system("cls");
}
cout << "Data written to file" << endl;
ofile.close();
return 0;
}
int random(int min, int max){
return rand()%(max-min + 1) + min;
}