192int main(
int argc,
char * argv[])
194 TCLAP::CmdLine
cmd(
"Generate random euclidian graph",
' ',
"1.0");
196 TCLAP::ValueArg<size_t> nArg(
"n",
"nodes",
"Number of nodes",
false, 100,
"size_t");
197 TCLAP::ValueArg<size_t> mArg(
"m",
"edges",
"Number of edges",
false, 1000,
"size_t");
198 TCLAP::ValueArg<int> wArg(
"W",
"width",
"Width",
false, 1000,
"int");
199 TCLAP::ValueArg<int> hArg(
"H",
"height",
"Height",
false, 1000,
"int");
200 TCLAP::ValueArg<unsigned int> seedArg(
"s",
"seed",
"Random seed",
false, 0,
"unsigned int");
201 TCLAP::UnlabeledValueArg<string> fileArg(
"file",
"Output file name",
false,
"",
"string");
211 cmd.parse(argc, argv);
212 }
catch (TCLAP::ArgException &e) {
213 cerr <<
"error: " << e.error() <<
" for arg " << e.argId() << endl;
217 size_t n = nArg.getValue();
218 size_t m = mArg.getValue();
219 int w = wArg.getValue();
220 int h = hArg.getValue();
221 unsigned int seed = seedArg.getValue();
222 string fileName = fileArg.getValue();
225 seed = time(
nullptr);
227 cout << argv[0] <<
" " << n <<
" " <<
m <<
" " <<
w <<
" " <<
h <<
" "
230 cout <<
"Preparing system stack size to 256 Mb ... " << endl
233 const rlim_t kStackSize = 256 * 1024 * 1024;
237 result = getrlimit(RLIMIT_STACK, &rl);
239 if (rl.rlim_cur < kStackSize)
241 rl.rlim_cur = kStackSize;
242 result = setrlimit(RLIMIT_STACK, &rl);
244 fprintf(stderr,
"setrlimit returned result = %d\n", result);
246 cout <<
"OK. done!" << endl
250 cout <<
"Generating graph ... " << endl;
252 Graph g = gen_random_euclidian_graph<Graph>(n,
m,
w,
h,
seed);
256 ofstream
out(fileName);
258 (g).save_in_text_mode(
out);
262 (g).save_in_text_mode(cout);