//Function to read in from Graph file and initialize all values for links //and number of nodes int initialize(char *x){ //Code to read from file ifstream infile; infile.open(x); if (!infile) { cout << "There was a problem opening " << x << " for reading."<< endl; return 1; } //Get the number of nodes from Graph.txt infile >> N; //Get number of links from Graph.txt infile >> L; //set all node names for(int i = 0; i < N; i++){ node[i].name = i; node[i].service_time = exponential(1.0); } //create all links with proper information. for(int i = 0; i < L; i++) { lnk[i].delay = uniformInt(); lnk[i].bandwidth = uniformDouble(); infile >> lnk[i].node_1; infile >> lnk[i].node_2; } //close Graph.txt infile.close(); return 0; }
bool probability( double prob ) { if( prob > uniformDouble( 0, 100 ) ) { return true; } else { return false; } }