00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <cstdio>
00010 #include <cstdlib>
00011 #include <algorithm>
00012
00013 int
00014 main(int argc, char* argv[])
00015 {
00016 if (argc != 4) {
00017 printf("Usage: gen4 <nodenum> <maxweigth> <seed>\n");
00018 return -1;
00019 }
00020
00021 const int num = atoi(argv[1]);
00022 const int maxw = atoi(argv[2]);
00023 const int seed = atoi(argv[3]);
00024
00025 srand48(seed);
00026
00027 printf("%i %i\n", num*num, 2*num*num-2*num);
00028
00029 for (int i = 0; i < num; ++i) {
00030 const int colstart = i * num + 1;
00031 for (int j = 0; j < num; ++j) {
00032 const int w0 = static_cast<int>((2*maxw+1) * drand48()) - maxw;
00033 printf("%3i %3i %i\n", colstart+j-1, colstart+j, w0);
00034 const int w1 = static_cast<int>((2*maxw+1) * drand48()) - maxw;
00035 printf("%3i %3i %i\n", colstart+j-1, colstart+j+num-1, w1);
00036 }
00037 }
00038 return 0;
00039 }