48 void getParameter(
int argc,
char ** argv,
int index, T & param,
bool & alreadyRegistered);
50 int main(
int argc,
char ** argv)
52 cout <<
"Topology generator" << endl;
53 cout <<
"LAAS-CNRS, 2006-2011, 7 avenue du Colonel Roche, Toulouse, France" << endl;
54 cout <<
"Contact: yannick.pencole@laas.fr" << endl;
55 bool nbNodeRegistered =
false;
57 bool connectivityRegistered =
false;
58 unsigned connectivity = 2;
59 bool cliqueSizeMaxRegistered =
false;
60 unsigned cliqueSizeMax = 2;
61 bool commonConnectionMaxRegistered =
false;
62 unsigned commonConnectionMax = 2;
63 bool seedRegistered =
false;
66 bool outputRegistered =
false;
75 string currentParameter = argv[1];
76 if(currentParameter ==
"--help")
87 string currentParameter = argv[index];
89 if(currentParameter ==
"--nodes") { param = 0; }
90 if((param == -1) && (currentParameter ==
"--connectivity")) { param = 1; }
91 if((param == -1) && (currentParameter ==
"--commonConnectionMax")) { param = 2; }
92 if((param == -1) && (currentParameter ==
"--cliqueSizeMax")) { param = 3; }
93 if((param == -1) && (currentParameter ==
"--seed")) { param = 4; }
94 if((param == -1) && (currentParameter ==
"--output")) { param = 5; }
99 getParameter<unsigned>(argc,argv,index, nbNode, nbNodeRegistered);
102 cout <<
"The number of nodes must be greater than 0" << endl;
109 getParameter<unsigned>(argc,argv,index, connectivity, connectivityRegistered);
112 cout <<
"The maximal connectivity of a node must be at least 2" << endl;
119 getParameter<unsigned>(argc,argv,index, commonConnectionMax, commonConnectionMaxRegistered);
120 if(commonConnectionMax < 1)
122 cout <<
"The maximal connectivity between two nodes must be at least 1" << endl;
129 getParameter<unsigned>(argc,argv,index, cliqueSizeMax,cliqueSizeMaxRegistered);
130 if(cliqueSizeMax < 2)
132 cout <<
"The maximal clique size must be at least 2" << endl;
139 getParameter<unsigned>(argc,argv,index, seed, seedRegistered);
144 getParameter<string>(argc,argv,index, output, outputRegistered);
149 cout <<
"The parameter " << currentParameter <<
" is not recognized." << endl << endl;
160 commonConnectionMax,seed,topology);
163 topology.
save(output);
164 cout <<
"Topology saved in " << output <<
"." << endl;
169 stream <<
"generatedTopology_";
170 stream << nbNode <<
"_";
171 stream << connectivity <<
"_";
172 stream << cliqueSizeMax <<
"_";
173 stream << commonConnectionMax <<
"_";
176 topology.
save(stream.str());
177 cout <<
"Topology saved in " << stream.str() <<
"." << endl;
184 cout <<
"Usage: GenerateTopology " << endl;
185 cout <<
"\t [--nodes nbNode] " << endl;
186 cout <<
"\t [--connectivity nbConn] " << endl;
187 cout <<
"\t [--commonConnectionMax nbConn]" << endl;
188 cout <<
"\t [--cliqueSizeMax cliqueSize]" << endl;
189 cout <<
"\t [--seed randomSeed]" << endl;
190 cout <<
"\t [--output fileName]" << endl;
192 cout <<
"Generate a topology of 'nbNode' nodes (default = 3). A connection " << endl;
193 cout <<
"between a set of nodes corresponds to a set of synchronised events " << endl;
194 cout <<
"between the nodes. Any node is directly or indirectly connected " << endl;
195 cout <<
"to the other nodes. The connectivity of a node is the set of connections " << endl;
196 cout <<
"in which the node is involved (default = 2). The parameter " << endl;
197 cout <<
"'connectivity' sets the maximal number of connections that a node can " << endl;
198 cout <<
"have. A connection involves a set of nodes (that is then called a clique). " << endl;
199 cout <<
"'cliqueSizeMax' sets the maximal size of a clique (default = 2). Two nodes " << endl;
200 cout <<
"may have several connections in common, 'commonConnectionMax' sets the " << endl;
201 cout <<
"maximal number of connections involving two components (default = 2). " << endl;
202 cout <<
"The generation is random and require a seed " << endl;
203 cout <<
"(default = depends on the time). Two runs with the same seed and parameters " << endl;
204 cout <<
"generate the same topology. The topology is then saved in the 'fileName' " << endl;
205 cout <<
"(default = \"generatedTopology+Params.topo\") " << endl;
211 void getParameter(
int argc,
char ** argv,
int index, T & param,
bool & alreadyRegistered)
213 if(!alreadyRegistered)
215 if(argc == index + 1)
217 cout <<
"The parameter " << argv[index] <<
" is not correct" << endl << endl;
223 stream << argv[index + 1];
226 alreadyRegistered =
true;
230 cout <<
"The parameter " << argv[index + 1] <<
" has an incorrect format" << endl << endl;
unsigned initialiseSeed()
int main(int argc, char **argv)
void generateTopology(unsigned nbComp, unsigned connectivity, unsigned nbSharedMax, Graph &topology, NodeMap< unsigned > &compIds)
Random generation utilities.
void getParameter(int argc, char **argv, int index, T ¶m, bool &alreadyRegistered)
void save(const string &fileName)