/* FILE: randDigraphW.cpp last change: 6-Feb-2014 author: Romeo Rizzi * randomly generates a weighted digraph with node 0 guaranteed to reach all the others. * Usage syntax: * > randGraph n m max_w seed */ #include #include #include #include using namespace std; const int MAX_N = 100000; long long int n; const int MAX_M = 2000000; long long int m; const int MAX_W = 100; int max_w; int RandNumber(int min, int max) { return min + (int) ( (max-min +1) * (double( rand()-0.000000000001 ) / RAND_MAX ) ); } int main(int argc, char** argv) { n = atoi(argv[1]); m = atoi(argv[2]); max_w = atoi(argv[3]); assert(n <= MAX_N); assert(m <= MAX_M); assert( max_w <= MAX_W ); assert(n >= 1); assert(m <= MAX_M); assert( max_w <= MAX_W ); assert( m >= n-1); assert( m <= (n*(n-1)) ); srand(time(NULL)); if(argc > 4) srand( atoi(argv[4]) ); cout << n << " " << m << endl; for(int i = 1; i