//Brandon S. Parker //April 18, 2003 //generator.cc //========================= //************************************************************** //* Graph Adj. Matrix Generator: * //* * //* Source file: generator.cc Vers. 1.0 * //* * //* Input: command line arguments * //* * //* Output: console and ASCII file * //* * //* Compile with: g++ -o generator generator.cc * //* * //* Objective: Provide complete graphs for analysis * //* * //* License: GPL - http://www.gnu.org/copyleft/gpl.html * //* * //* For more information, see http://www.brandonparker.net * //* * //* Author: * //* Brandon S. Parker * //* (c) 2003 by Brandon S. Parker * //* * //************************************************************** #include #include #include #include #include #include #include #define VERSION "1.0" #define COPYRIGHT "(c)2003 Brandon Parker" #define INFINITE 65535 #define MAXDIM 60000 //***Prototypes: int CmdParse(int argv, char *argc[], char filename[], bool *QUIET, int *TYPE, int *MAX_W, int *n); double getNOWTime(); double getCPUTime(); //************ //*** MAIN *** //************ int main(int argv, char *argc[]) { //*** Definitions: srand((unsigned int)getCPUTime()); //*** seed randomize with currect time for uniqueness char filename[88]; //*** Output filename strcpy(filename, "AdjMatrix.mtx"); bool QUIET = false; //*** true = print to file, false = print to STDOUT only int TYPE = 1; //*** graph type: (1) Sparse, (2) Dense, (3) Mid/Random (4) Complete int MAX_W = 60000; //*** Max weight allowed in the graph. Set to '1' for unweighted int n = 25; //*** number of graph nodes/ matrix dimension CmdParse(argv, argc, filename, &QUIET, &TYPE, &MAX_W, &n); ofstream FILE(filename); //*** ASCII output file if (!QUIET) FILE< []"< (i+1)) && (argc[i+1][0] != '-')) strcpy(filename, argc[i+1]); break; case 'v': cout< [-f ] [-vhq]"< 0) && (argc[i-1][1] != 'f')) *n = atoi(argc[i]); } return 1; } //************************************************ double getCPUTime() { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_usec; } //************************************************ double getNOWTime() { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec*1e+06 + tv.tv_usec; } //*************************************** //*** Foot-Notes *** //*************************************** // // ---------------------------------------------------- // 1.) Proof of Connected minimum edge graph algorithm: // ---------------------------------------------------- // Proof by induction: // LET: // a.) G be a graph of n nodes // b.) M[n][n] be the Adjacency Matrix for G. // // Note: // a.) For any i such that 0i] can be disregarded as the // contained value is a duplicate. // // Algorithm: // For each i = 1 to n // choose a value of j such that 0