graph_build.cpp 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008
  1. /**
  2. * @file tests/boost_graph/partitioning/graph_build.cpp
  3. * @author The PARADEVS Development Team
  4. * See the AUTHORS or Authors.txt file
  5. */
  6. /*
  7. * PARADEVS - the multimodeling and simulation environment
  8. * This file is a part of the PARADEVS environment
  9. *
  10. * Copyright (C) 2013-2015 ULCO http://www.univ-litoral.fr
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation, either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. #include <tests/boost_graph/partitioning/graph_build.hpp>
  26. #include <iostream>
  27. //#include <tests/corsen/lib/Corsen.hpp>
  28. namespace paradevs { namespace tests { namespace boost_graph {
  29. void build_graph(OrientedGraph& og, unsigned int edge_number)
  30. {
  31. if(edge_number == 11){
  32. vertex_to v0 = boost::add_vertex(og);
  33. vertex_to v1 = boost::add_vertex(og);
  34. vertex_to v2 = boost::add_vertex(og);
  35. vertex_to v3 = boost::add_vertex(og);
  36. vertex_to v4 = boost::add_vertex(og);
  37. vertex_to v5 = boost::add_vertex(og);
  38. vertex_to v6 = boost::add_vertex(og);
  39. vertex_to v7 = boost::add_vertex(og);
  40. vertex_to v8 = boost::add_vertex(og);
  41. vertex_to v9 = boost::add_vertex(og);
  42. vertex_to v10 = boost::add_vertex(og);
  43. add_edge(v1, v0, EdgeProperties(2.), og);
  44. add_edge(v2, v0, EdgeProperties(1.5), og);
  45. add_edge(v3, v0, EdgeProperties(1.5), og);
  46. add_edge(v1, v2, EdgeProperties(3.), og);
  47. add_edge(v4, v1, EdgeProperties(3.), og);
  48. add_edge(v5, v1, EdgeProperties(3.), og);
  49. add_edge(v6, v1, EdgeProperties(3.), og);
  50. add_edge(v6, v2, EdgeProperties(2.), og);
  51. add_edge(v2, v3, EdgeProperties(1.), og);
  52. add_edge(v9, v3, EdgeProperties(1.), og);
  53. add_edge(v10, v3, EdgeProperties(1.), og);
  54. add_edge(v4, v5, EdgeProperties(1.5), og);
  55. add_edge(v5, v6, EdgeProperties(1.5), og);
  56. add_edge(v7, v4, EdgeProperties(1.), og);
  57. add_edge(v8, v4, EdgeProperties(1.), og);
  58. add_edge(v7, v8, EdgeProperties(1.5), og);
  59. add_edge(v9, v10, EdgeProperties(2.), og);
  60. og[v6] = VertexProperties(6, 1.5, NORMAL_PIXEL);
  61. og[v8] = VertexProperties(8, 1., NORMAL_PIXEL);
  62. og[v10] = VertexProperties(10, 1.5, NORMAL_PIXEL);
  63. og[v0] = VertexProperties(0, 3, NORMAL_PIXEL);
  64. og[v1] = VertexProperties(1, 2, NORMAL_PIXEL);
  65. og[v2] = VertexProperties(2, 2, NORMAL_PIXEL);
  66. og[v3] = VertexProperties(3, 2, NORMAL_PIXEL);
  67. og[v4] = VertexProperties(4, 1.5, NORMAL_PIXEL);
  68. og[v5] = VertexProperties(5, 1.5, NORMAL_PIXEL);
  69. og[v7] = VertexProperties(7, 1., TOP_PIXEL);
  70. og[v9] = VertexProperties(9, 1.5, TOP_PIXEL);
  71. } else if(edge_number == 38){
  72. vertex_to v0 = boost::add_vertex(og);
  73. vertex_to v1 = boost::add_vertex(og);
  74. vertex_to v2 = boost::add_vertex(og);
  75. vertex_to v3 = boost::add_vertex(og);
  76. vertex_to v4 = boost::add_vertex(og);
  77. vertex_to v5 = boost::add_vertex(og);
  78. vertex_to v6 = boost::add_vertex(og);
  79. vertex_to v7 = boost::add_vertex(og);
  80. vertex_to v8 = boost::add_vertex(og);
  81. vertex_to v9 = boost::add_vertex(og);
  82. vertex_to v10 = boost::add_vertex(og);
  83. vertex_to v11 = boost::add_vertex(og);
  84. vertex_to v12 = boost::add_vertex(og);
  85. vertex_to v13 = boost::add_vertex(og);
  86. vertex_to v14 = boost::add_vertex(og);
  87. vertex_to v15 = boost::add_vertex(og);
  88. vertex_to v16 = boost::add_vertex(og);
  89. vertex_to v17 = boost::add_vertex(og);
  90. vertex_to v18 = boost::add_vertex(og);
  91. vertex_to v19 = boost::add_vertex(og);
  92. vertex_to v20 = boost::add_vertex(og);
  93. vertex_to v21 = boost::add_vertex(og);
  94. vertex_to v22 = boost::add_vertex(og);
  95. vertex_to v23 = boost::add_vertex(og);
  96. vertex_to v24 = boost::add_vertex(og);
  97. vertex_to v25 = boost::add_vertex(og);
  98. vertex_to v26 = boost::add_vertex(og);
  99. vertex_to v27 = boost::add_vertex(og);
  100. vertex_to v28 = boost::add_vertex(og);
  101. vertex_to v29 = boost::add_vertex(og);
  102. vertex_to v30 = boost::add_vertex(og);
  103. vertex_to v31 = boost::add_vertex(og);
  104. vertex_to v32 = boost::add_vertex(og);
  105. vertex_to v33 = boost::add_vertex(og);
  106. vertex_to v34 = boost::add_vertex(og);
  107. vertex_to v35 = boost::add_vertex(og);
  108. vertex_to v36 = boost::add_vertex(og);
  109. vertex_to v37 = boost::add_vertex(og);
  110. add_edge(v1, v0, EdgeProperties(1.), og);
  111. add_edge(v2, v0, EdgeProperties(1.), og);
  112. add_edge(v3, v0, EdgeProperties(1.), og);
  113. add_edge(v1, v2, EdgeProperties(1.), og);
  114. add_edge(v4, v1, EdgeProperties(1.), og);
  115. add_edge(v5, v1, EdgeProperties(1.), og);
  116. add_edge(v6, v1, EdgeProperties(1.), og);
  117. add_edge(v6, v2, EdgeProperties(1.), og);
  118. add_edge(v2, v3, EdgeProperties(1.), og);
  119. add_edge(v9, v3, EdgeProperties(1.), og);
  120. add_edge(v10, v3, EdgeProperties(1.), og);
  121. add_edge(v4, v5, EdgeProperties(1.), og);
  122. add_edge(v5, v6, EdgeProperties(1.), og);
  123. add_edge(v7, v4, EdgeProperties(1.), og);
  124. add_edge(v8, v4, EdgeProperties(1.), og);
  125. add_edge(v7, v8, EdgeProperties(1.), og);
  126. add_edge(v9, v10, EdgeProperties(1.), og);
  127. add_edge(v8, v11, EdgeProperties(1.), og);
  128. add_edge(v11, v4, EdgeProperties(1.), og);
  129. add_edge(v12, v13, EdgeProperties(1.), og);
  130. add_edge(v12, v7, EdgeProperties(1.), og);
  131. add_edge(v13, v7, EdgeProperties(1.), og);
  132. add_edge(v14, v15, EdgeProperties(1.), og);
  133. add_edge(v14, v12, EdgeProperties(1.), og);
  134. add_edge(v15, v16, EdgeProperties(1.), og);
  135. add_edge(v15, v12, EdgeProperties(1.), og);
  136. add_edge(v16, v17, EdgeProperties(1.), og);
  137. add_edge(v16, v12, EdgeProperties(1.), og);
  138. add_edge(v17, v12, EdgeProperties(1.), og);
  139. add_edge(v18, v19, EdgeProperties(1.), og);
  140. add_edge(v18, v8, EdgeProperties(1.), og);
  141. add_edge(v19, v20, EdgeProperties(1.), og);
  142. add_edge(v19, v8, EdgeProperties(1.), og);
  143. add_edge(v20, v8, EdgeProperties(1.), og);
  144. add_edge(v21, v22, EdgeProperties(1.), og);
  145. add_edge(v21, v19, EdgeProperties(1.), og);
  146. add_edge(v22, v23, EdgeProperties(1.), og);
  147. add_edge(v22, v19, EdgeProperties(1.), og);
  148. add_edge(v23, v19, EdgeProperties(1.), og);
  149. add_edge(v24, v25, EdgeProperties(1.), og);
  150. add_edge(v24, v6, EdgeProperties(1.), og);
  151. add_edge(v25, v6, EdgeProperties(1.), og);
  152. add_edge(v26, v11, EdgeProperties(1.), og);
  153. add_edge(v26, v27, EdgeProperties(1.), og);
  154. add_edge(v26, v24, EdgeProperties(1.), og);
  155. add_edge(v27, v24, EdgeProperties(1.), og);
  156. add_edge(v28, v25, EdgeProperties(1.), og);
  157. add_edge(v29, v27, EdgeProperties(1.), og);
  158. add_edge(v29, v28, EdgeProperties(1.), og);
  159. add_edge(v30, v27, EdgeProperties(1.), og);
  160. add_edge(v30, v28, EdgeProperties(1.), og);
  161. add_edge(v31, v32, EdgeProperties(1.), og);
  162. add_edge(v31, v10, EdgeProperties(1.), og);
  163. add_edge(v32, v33, EdgeProperties(1.), og);
  164. add_edge(v32, v10, EdgeProperties(1.), og);
  165. add_edge(v33, v10, EdgeProperties(1.), og);
  166. add_edge(v34, v31, EdgeProperties(1.), og);
  167. add_edge(v34, v35, EdgeProperties(1.), og);
  168. add_edge(v35, v31, EdgeProperties(1.), og);
  169. add_edge(v35, v32, EdgeProperties(1.), og);
  170. add_edge(v36, v32, EdgeProperties(1.), og);
  171. add_edge(v36, v37, EdgeProperties(1.), og);
  172. add_edge(v36, v33, EdgeProperties(1.), og);
  173. add_edge(v37, v33, EdgeProperties(1.), og);
  174. og[v6] = VertexProperties(6, 2.5, NORMAL_PIXEL);
  175. og[v8] = VertexProperties(8, 2., NORMAL_PIXEL);
  176. og[v10] = VertexProperties(10, 2.5, NORMAL_PIXEL);
  177. og[v0] = VertexProperties(0, 4, NORMAL_PIXEL);
  178. og[v1] = VertexProperties(1, 3, NORMAL_PIXEL);
  179. og[v2] = VertexProperties(2, 3, NORMAL_PIXEL);
  180. og[v3] = VertexProperties(3, 3, NORMAL_PIXEL);
  181. og[v4] = VertexProperties(4, 2.5, NORMAL_PIXEL);
  182. og[v5] = VertexProperties(5, 2.5, NORMAL_PIXEL);
  183. og[v7] = VertexProperties(7, 2., NORMAL_PIXEL);
  184. og[v9] = VertexProperties(9, 2.5, TOP_PIXEL);
  185. og[v11] = VertexProperties(11, 2, NORMAL_PIXEL);
  186. og[v12] = VertexProperties(12, 1.5, NORMAL_PIXEL);
  187. og[v13] = VertexProperties(13, 1.5, NORMAL_PIXEL);
  188. og[v14] = VertexProperties(14, 1, TOP_PIXEL);
  189. og[v15] = VertexProperties(15, 1, NORMAL_PIXEL);
  190. og[v16] = VertexProperties(16, 1, NORMAL_PIXEL);
  191. og[v17] = VertexProperties(17, 1, NORMAL_PIXEL);
  192. og[v18] = VertexProperties(18, 1.5, TOP_PIXEL);
  193. og[v19] = VertexProperties(19, 1.5, NORMAL_PIXEL);
  194. og[v20] = VertexProperties(20, 1.5, NORMAL_PIXEL);
  195. og[v21] = VertexProperties(21, 1, TOP_PIXEL);
  196. og[v22] = VertexProperties(22, 1, NORMAL_PIXEL);
  197. og[v23] = VertexProperties(23, 1, NORMAL_PIXEL);
  198. og[v24] = VertexProperties(24, 2, NORMAL_PIXEL);
  199. og[v25] = VertexProperties(25, 2, NORMAL_PIXEL);
  200. og[v26] = VertexProperties(26, 1.5, TOP_PIXEL);
  201. og[v27] = VertexProperties(27, 1.5, NORMAL_PIXEL);
  202. og[v28] = VertexProperties(28, 1.5, NORMAL_PIXEL);
  203. og[v29] = VertexProperties(29, 1, TOP_PIXEL);
  204. og[v30] = VertexProperties(30, 1, TOP_PIXEL);
  205. og[v31] = VertexProperties(31, 2, NORMAL_PIXEL);
  206. og[v32] = VertexProperties(32, 2, NORMAL_PIXEL);
  207. og[v33] = VertexProperties(33, 2, NORMAL_PIXEL);
  208. og[v34] = VertexProperties(34, 1.5, TOP_PIXEL);
  209. og[v35] = VertexProperties(35, 1.5, NORMAL_PIXEL);
  210. og[v36] = VertexProperties(36, 1.5, TOP_PIXEL);
  211. og[v37] = VertexProperties(37, 1.5, NORMAL_PIXEL);
  212. }else{
  213. std::cout<<"Le type de artificiel graphe choisi n'existe pas ! "<<std::endl;
  214. }
  215. }
  216. void modify_file_paths(std::string& absolutePath,
  217. std::vector < std::string* >& files)
  218. {
  219. for (std::vector < std::string* >::iterator it = files.begin();
  220. it != files.end(); it++) {
  221. (*it)->insert(0, absolutePath);
  222. }
  223. }
  224. void build_graph_cyclique(OrientedGraph& og)
  225. {
  226. vertex_to v0 = boost::add_vertex(og);
  227. vertex_to v1 = boost::add_vertex(og);
  228. vertex_to v2 = boost::add_vertex(og);
  229. vertex_to v3 = boost::add_vertex(og);
  230. vertex_to v4 = boost::add_vertex(og);
  231. vertex_to v5 = boost::add_vertex(og);
  232. vertex_to v6 = boost::add_vertex(og);
  233. vertex_to v7 = boost::add_vertex(og);
  234. vertex_to v8 = boost::add_vertex(og);
  235. vertex_to v9 = boost::add_vertex(og);
  236. vertex_to v10 = boost::add_vertex(og);
  237. add_edge(v0, v1, EdgeProperties(1.), og);
  238. add_edge(v0, v2, EdgeProperties(1.), og);
  239. add_edge(v0, v3, EdgeProperties(1.), og);
  240. add_edge(v1, v3, EdgeProperties(1.), og);
  241. add_edge(v2, v1, EdgeProperties(1.), og);
  242. add_edge(v2, v3, EdgeProperties(1.), og);
  243. add_edge(v2, v4, EdgeProperties(1.), og);
  244. add_edge(v2, v5, EdgeProperties(1.), og);
  245. add_edge(v2, v7, EdgeProperties(1.), og);
  246. add_edge(v2, v9, EdgeProperties(1.), og);
  247. add_edge(v3, v4, EdgeProperties(1.), og);
  248. add_edge(v3, v5, EdgeProperties(1.), og);
  249. add_edge(v3, v7, EdgeProperties(1.), og);
  250. add_edge(v3, v9, EdgeProperties(1.), og);
  251. add_edge(v4, v6, EdgeProperties(1.), og);
  252. add_edge(v5, v4, EdgeProperties(1.), og);
  253. add_edge(v5, v6, EdgeProperties(1.), og);
  254. add_edge(v6, v7, EdgeProperties(1.), og);
  255. add_edge(v7, v8, EdgeProperties(1.), og);
  256. add_edge(v7, v10, EdgeProperties(1.), og);
  257. add_edge(v8, v9, EdgeProperties(1.), og);
  258. add_edge(v8, v10, EdgeProperties(1.), og);
  259. add_edge(v9, v10, EdgeProperties(1.), og);
  260. add_edge(v10, v0, EdgeProperties(1.), og);
  261. og[v6] = VertexProperties(6, 1, NORMAL_PIXEL);
  262. og[v8] = VertexProperties(8, 1, NORMAL_PIXEL);
  263. og[v10] = VertexProperties(10, 1, NORMAL_PIXEL);
  264. og[v0] = VertexProperties(0, 1, NORMAL_PIXEL);
  265. og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
  266. og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
  267. og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
  268. og[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
  269. og[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
  270. og[v7] = VertexProperties(7, 1, NORMAL_PIXEL);
  271. og[v9] = VertexProperties(9, 1, NORMAL_PIXEL);
  272. }
  273. /*void build_corsen_graph(OrientedGraph& graph)
  274. {
  275. std::string absolutePath(
  276. "/home/eric/vle/vle-labs/paradevs/src/tests/corsen/data_s/");
  277. std::string modeFile(".mode");
  278. std::string parametersFile("par.txt");
  279. std::string elevationFile("alt");
  280. std::string outletFile("arbre");
  281. std::string layersFile("couche");
  282. std::string contextFile("contexte_yar_scenario.xml");
  283. std::string slopeFile("pav");
  284. std::vector < std::string* > files;
  285. Corsen c;
  286. files.push_back(&parametersFile);
  287. files.push_back(&modeFile);
  288. files.push_back(&elevationFile);
  289. files.push_back(&outletFile);
  290. files.push_back(&slopeFile);
  291. files.push_back(&contextFile);
  292. files.push_back(&layersFile);
  293. modify_file_paths(absolutePath, files);
  294. c.read(files, absolutePath);
  295. c.buildGraph();
  296. const DirectedGraph& g = c.getGraph().graph();
  297. std::vector < vertex_t > og_vertex_list;
  298. std::vector < vertex_t > dg_vertex_list;
  299. std::vector < int > dg_in_vertex_list;
  300. DirectedGraph::vertex_iterator it_dg, end_dg;
  301. tie(it_dg, end_dg) = vertices(g);
  302. for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
  303. og_vertex_list.push_back(add_vertex(graph));
  304. dg_vertex_list.push_back(*it_dg);
  305. dg_in_vertex_list.push_back(0);
  306. }
  307. tie(it_dg, end_dg) = vertices(g);
  308. for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
  309. DirectedGraph::adjacency_iterator neighbour_it, neighbour_end;
  310. tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_dg, g);
  311. for (; neighbour_it != neighbour_end; ++neighbour_it) {
  312. uint index = 0;
  313. while (dg_vertex_list[index] != *neighbour_it) {
  314. ++index;
  315. }
  316. ++dg_in_vertex_list[index];
  317. boost::add_edge(og_vertex_list[i], og_vertex_list[index],
  318. EdgeProperties(1.), graph);
  319. }
  320. }
  321. tie(it_dg, end_dg) = vertices(g);
  322. for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
  323. if (dg_in_vertex_list[i] == 0) {
  324. graph[og_vertex_list[i]] = VertexProperties(i, 1., TOP_PIXEL);
  325. } else {
  326. graph[og_vertex_list[i]] = VertexProperties(i, 1., NORMAL_PIXEL);
  327. }
  328. }
  329. }*/
  330. void brhtg_source(OrientedGraph *go,int nbr_vertex, int nbr_source, int nbr_v_min, int nbr_v_max, const std::vector<int> &niveau,
  331. std::vector<int> &Ram, std::vector<int> &Exu, const std::vector<vertex_to> &Vertexs,
  332. int nbr_passe, int nbr_npb){
  333. uint nbr_voisin;
  334. int niv=1;
  335. for(uint j =0; j<niveau.size()-1; j++){
  336. niv *= niveau.at(j);
  337. }
  338. int niv_tot=1;
  339. for(uint j =0; j<niveau.size(); j++){
  340. niv_tot *= niveau.at(j);
  341. }
  342. for(int b = 0; b<niv; b++){
  343. std::vector<uint> branche;
  344. int cpt = 0;
  345. while(cpt != niveau.at(niveau.size()-1)+1){
  346. branche.push_back((b*niveau.at(niveau.size()-1)+cpt)*nbr_npb);
  347. cpt++;
  348. }
  349. for(uint i =0; i<branche.size()-1;i++){
  350. for(uint j = branche.at(i); j<branche.at(i+1); j++){
  351. if(j==branche.at(branche.size()-1)-1){
  352. break;
  353. }
  354. else{
  355. nbr_voisin = rand_fini(nbr_v_min, nbr_v_max+1);
  356. uint cpt=0;
  357. Entiers ensemble;
  358. int cpt_nbr_s = 0;
  359. while(cpt != nbr_voisin){
  360. int val;
  361. if(j<branche.at(i)+nbr_source){ // Les sommets sont des sources donc imossible de recevoir des données
  362. val = rand_fini(j + 4, j + nbr_v_max + nbr_passe);
  363. }
  364. else if(j>=branche.at(i)+nbr_npb-nbr_passe && i!= (branche.size()-2)){ // Les sommets sont en fin de branche, nécessité de raccordement avec les autres branches
  365. val = rand_fini(branche.at(branche.size()-1)-4, branche.at(branche.size()-1));
  366. }
  367. else if(j>=branche.at(i)+nbr_npb-nbr_passe && i== (branche.size()-2)){ // Les sommets sont proche de l'exutoire
  368. val = rand_fini(j+1,branche.at(branche.size()-1));
  369. }
  370. else{ // Les sommets sont en plein milieu d'une branche
  371. val = rand_fini(j+1, j+nbr_passe);
  372. }
  373. if(In_tab(ensemble,val) != 1){
  374. ensemble.push_back(val);
  375. boost::add_edge(Vertexs.at(j), Vertexs.at(val), EdgeProperties(1.), *go);
  376. cpt++;
  377. }
  378. else{
  379. if((nbr_vertex-j) == cpt)
  380. break;
  381. else
  382. cpt_nbr_s++;
  383. }
  384. if(cpt_nbr_s>2*nbr_passe)
  385. break;
  386. }
  387. }
  388. }
  389. }
  390. /*for(int i =0; i<branche.size()-1; i++){
  391. for(int j = branche.at(i)+nbr_source; j<branche.at(i+1); j++){
  392. (*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
  393. }
  394. }
  395. for(int i =0; i<branche.size()-1; i++){
  396. for(int j = branche.at(i); j<branche.at(i)+nbr_source; j++){
  397. (*go)[Vertexs.at(j)] = VertexProperties(j, 1, TOP_PIXEL);
  398. }
  399. }*/
  400. Ram.push_back((niv_tot+b)*nbr_npb);
  401. Exu.push_back(branche.at(branche.size()-1)-1);
  402. }
  403. Ram.push_back(Ram.at(Ram.size()-1)+nbr_npb);
  404. if(niveau.size()>1){
  405. nbr_voisin = 2;
  406. for(uint k =0; k<Exu.size(); k++){
  407. for(uint l = Exu.at(k)-2; l<Exu.at(k)+1; l++){
  408. int cpt=0;
  409. Entiers ensemble;
  410. int cpt_nbr_s = 0;
  411. while(cpt!=nbr_voisin){
  412. int val = rand_fini(Ram.at(k),Ram.at(k)+2);
  413. if(In_tab(ensemble,val)!=1){
  414. ensemble.push_back(val);
  415. boost::add_edge(Vertexs.at(l), Vertexs.at(val), EdgeProperties(1.), *go);
  416. cpt++;
  417. }
  418. else{
  419. if((nbr_vertex-l)==cpt)
  420. break;
  421. else
  422. cpt_nbr_s++;
  423. }
  424. if(cpt_nbr_s>2*nbr_passe)
  425. break;
  426. }
  427. }
  428. }
  429. }
  430. }
  431. void brhtg_ramification(OrientedGraph *go, int nbr_vertex, int nbr_v_min, int nbr_v_max, const std::vector<int> &niveau,
  432. std::vector<int> &Ram, std::vector<int> &Exu, const std::vector<vertex_to> &Vertexs,
  433. int nbr_passe, int nbr_npb){
  434. int nbr_voisin;
  435. int cpt_ram = 1;
  436. while(cpt_ram != niveau.size()-1){
  437. int niv=1;
  438. for(int j =0; j<niveau.size()-1-cpt_ram; j++){
  439. niv *= niveau.at(j);
  440. }
  441. int niv_tot=0;
  442. for(int i =0; i<=cpt_ram; i++){
  443. int tmp_niv_tot=1;
  444. for(int j =0; j<niveau.size()-i; j++){
  445. tmp_niv_tot *= niveau.at(j);
  446. }
  447. niv_tot+=tmp_niv_tot;
  448. }
  449. std::vector<std::vector<int> > branche;
  450. int cpt_b=0;
  451. for(int j = 0; j<(Ram.size()-1)/niveau.at(niveau.size()-1-cpt_ram); j++){
  452. std::vector<int> tmp_branche;
  453. for(int i =0; i< niveau.at(niveau.size()-1-cpt_ram); i++){
  454. tmp_branche.push_back(Ram.at(i+cpt_b));
  455. }
  456. tmp_branche.push_back(tmp_branche.at(tmp_branche.size()-1)+nbr_npb);
  457. branche.push_back(tmp_branche);
  458. cpt_b+=niveau.at(niveau.size()-1-cpt_ram);
  459. }
  460. Ram.clear();
  461. Exu.clear();
  462. for(int b = 0; b<niv; b++){
  463. for(int i =0; i<branche.at(b).size()-1;i++){
  464. for(int j = branche.at(b).at(i); j<branche.at(b).at(i+1); j++){
  465. if(j==branche.at(b).at(branche.at(b).size()-1)-1){
  466. break;
  467. }
  468. else{
  469. nbr_voisin = rand_fini(nbr_v_min, nbr_v_max+1);
  470. int cpt=0;
  471. Entiers ensemble;
  472. int cpt_nbr_s = 0;
  473. while(cpt!=nbr_voisin){
  474. int val;
  475. if(j>=branche.at(b).at(i)+nbr_npb-nbr_passe && i!= (branche.at(b).size()-2)){ // Les sommets sont en fin de branche, nécessité de raccordement avec les autres branches
  476. val = rand_fini(branche.at(b).at(branche.at(b).size()-1)-4, branche.at(b).at(branche.at(b).size()-1));
  477. }
  478. else if(j>=branche.at(b).at(i)+nbr_npb-nbr_passe && i== (branche.at(b).size()-2)){ // Les sommets sont proche de l'exutoire
  479. val = rand_fini(j+1,branche.at(b).at(branche.at(b).size()-1));
  480. }
  481. else{ // Les sommets sont en plein milieu d'une branche
  482. val = rand_fini(j+1, j+nbr_passe);
  483. }
  484. if(In_tab(ensemble,val)!=1){
  485. ensemble.push_back(val);
  486. boost::add_edge(Vertexs.at(j), Vertexs.at(val), EdgeProperties(1.), *go);
  487. cpt++;
  488. }
  489. else{
  490. if((nbr_vertex-j)==cpt)
  491. break;
  492. else
  493. cpt_nbr_s++;
  494. }
  495. if(cpt_nbr_s>2*nbr_passe)
  496. break;
  497. }
  498. }
  499. }
  500. }
  501. Ram.push_back((niv_tot+b)*nbr_npb);
  502. Exu.push_back(branche.at(b).at(branche.at(b).size()-1)-1);
  503. /*for(int y =0; y<branche.at(b).size()-1; y++){
  504. for(int x = branche.at(b).at(y); x<branche.at(b).at(y+1); x++){
  505. (*go)[Vertexs.at(x)] = VertexProperties(x, 1, NORMAL_PIXEL);
  506. }
  507. }*/
  508. }
  509. Ram.push_back(Ram.at(Ram.size()-1)+nbr_npb);
  510. nbr_voisin = 2;
  511. for(int k =0; k<Exu.size(); k++){
  512. for(int l = Exu.at(k)-1; l<Exu.at(k)+1; l++){
  513. int cpt=0;
  514. Entiers ensemble;
  515. int cpt_nbr_s = 0;
  516. while(cpt!=nbr_voisin){
  517. int val = rand_fini(Ram.at(k),Ram.at(k)+2);
  518. if(In_tab(ensemble,val)!=1){
  519. ensemble.push_back(val);
  520. boost::add_edge(Vertexs.at(l), Vertexs.at(val), EdgeProperties(1.), *go);
  521. cpt++;
  522. }
  523. else{
  524. if((nbr_vertex-l)==cpt)
  525. break;
  526. else
  527. cpt_nbr_s++;
  528. }
  529. if(cpt_nbr_s>2*nbr_passe)
  530. break;
  531. }
  532. }
  533. }
  534. cpt_ram++;
  535. }
  536. }
  537. void brhtg_exutoire(OrientedGraph *go,int nbr_vertex,int nbr_v_min, int nbr_v_max,
  538. std::vector<int> &Ram, const std::vector<vertex_to> &Vertexs,
  539. int nbr_passe){
  540. int nbr_voisin;
  541. Ram.at(Ram.size()-1)=nbr_vertex;
  542. for(int i =0; i<Ram.size()-1;i++){
  543. for(int j = Ram.at(i); j<Ram.at(i+1); j++){
  544. if(j==Ram.at(Ram.size()-1)-1){
  545. //(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
  546. break;
  547. }
  548. else{
  549. if(Ram.at(i+1)-j<nbr_passe)
  550. nbr_voisin = 2;
  551. else
  552. nbr_voisin = rand_fini(nbr_v_min, nbr_v_max+1);
  553. int cpt=0;
  554. Entiers ensemble;
  555. int cpt_nbr_s = 0;
  556. while(cpt!=nbr_voisin){
  557. int val;
  558. if(j>=Ram.at(i+1)-nbr_passe && i!=Ram.size()-2){ // Les sommets sont proche de l'exutoire
  559. val = rand_fini(Ram.at(Ram.size()-1)-4,Ram.at(Ram.size()-1));
  560. }
  561. else if(j>=Ram.at(i+1)-nbr_passe && i==Ram.size()-2){ // Les sommets sont proche de l'exutoire
  562. val = rand_fini(j+1,Ram.at(Ram.size()-1));
  563. }
  564. else{ // Les sommets sont en plein milieu d'une branche
  565. val = rand_fini(j+1, j+nbr_passe);
  566. }
  567. if(In_tab(ensemble,val)!=1&& j!=val){
  568. ensemble.push_back(val);
  569. boost::add_edge(Vertexs.at(j), Vertexs.at(val), EdgeProperties(1.), *go);
  570. cpt++;
  571. }
  572. else{
  573. if((nbr_vertex-j)==cpt)
  574. break;
  575. else
  576. cpt_nbr_s++;
  577. }
  578. if(cpt_nbr_s>2*nbr_passe)
  579. break;
  580. }
  581. }
  582. //(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
  583. }
  584. }
  585. }
  586. void build_generator_graph(OrientedGraph *go, int nbr_vertex, int nbr_source, int nbr_v_min, int nbr_v_max,const std::vector<int> &niveau){
  587. std::vector<vertex_to> Vertexs;
  588. int nbr_npb;
  589. int nbr_branche = 0;
  590. int nbr_passe = 4;
  591. for(int i =0; i<nbr_vertex; i++){
  592. vertex_to vo = boost::add_vertex(*go);
  593. Vertexs.push_back(vo);
  594. }
  595. // Calcul du nombre de branches à partir de l'information des niveaux
  596. for(int i =0; i< niveau.size(); i++){
  597. int nbr_tmp =1;
  598. for(int j =0; j<=i; j++){
  599. nbr_tmp *= niveau.at(j);
  600. }
  601. nbr_branche += nbr_tmp;
  602. }
  603. nbr_npb = nbr_vertex/(nbr_branche);
  604. std::vector<int> Ram;
  605. std::vector<int> Exu;
  606. if(niveau.size()>1){
  607. /*
  608. * *** Code Source ***
  609. */
  610. brhtg_source(go,nbr_vertex,nbr_source,nbr_v_min,nbr_v_max,niveau,Ram,Exu,Vertexs,nbr_passe,nbr_npb);
  611. /*
  612. * *** Code Ramifications ***
  613. */
  614. brhtg_ramification(go,nbr_vertex,nbr_v_min,nbr_v_max,niveau,
  615. Ram,Exu,Vertexs,nbr_passe,nbr_npb);
  616. /*
  617. * *** Code Exutoire ***
  618. */
  619. brhtg_exutoire(go,nbr_vertex,nbr_v_min,nbr_v_max,
  620. Ram,Vertexs,nbr_passe);
  621. } else {
  622. brhtg_source(go,nbr_vertex,nbr_source,nbr_v_min,nbr_v_max,niveau,Ram,Exu,Vertexs,nbr_passe,nbr_npb);
  623. }
  624. std::vector < int > dg_in_vertex_list;
  625. std::vector <vertex_to> dg_vertex_list;
  626. OrientedGraph::vertex_iterator it_dg, end_dg;
  627. tie(it_dg, end_dg) = vertices(*go);
  628. for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
  629. dg_in_vertex_list.push_back(0);
  630. dg_vertex_list.push_back(*it_dg);
  631. }
  632. tie(it_dg, end_dg) = vertices(*go);
  633. for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
  634. OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
  635. tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_dg, *go);
  636. for (; neighbour_it != neighbour_end; ++neighbour_it) {
  637. uint index = 0;
  638. while (dg_vertex_list[index] != *neighbour_it) {
  639. ++index;
  640. }
  641. ++dg_in_vertex_list[index];
  642. }
  643. }
  644. for(uint i = 0; i<num_vertices(*go); i++){
  645. if(dg_in_vertex_list.at(i) == 0){
  646. (*go)[i] = VertexProperties(i, 1, TOP_PIXEL);
  647. }else{
  648. (*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
  649. }
  650. }
  651. }
  652. void build_generator_graph_linked(OrientedGraph *go, int nbr_vertex, int nbr_couche, int nbr_v_min, int nbr_v_max){
  653. std::vector<vertex_to> Vertexs;
  654. for(int i =0; i<nbr_vertex; i++){
  655. vertex_to vo = boost::add_vertex(*go);
  656. Vertexs.push_back(vo);
  657. }
  658. /*Création du vecteur contenant le nombre de sommets par couche*/
  659. int midel_couche = nbr_couche-2;
  660. int top_couche;
  661. if(nbr_couche>5){
  662. top_couche = floor(nbr_vertex/floor(midel_couche/2));
  663. }else{
  664. top_couche = floor(nbr_vertex/2);
  665. }
  666. int nbr_vertex_midel_couche = nbr_vertex - top_couche -1;
  667. int tmp = 0;
  668. std::vector<int> nbr_som_couche;
  669. nbr_som_couche.push_back(1);
  670. for(int i = 1; i <= midel_couche; i++){
  671. tmp += i;
  672. }
  673. for(int i = 0; i < midel_couche; i++){
  674. nbr_som_couche.push_back(floor((i+1)*nbr_vertex_midel_couche/tmp));
  675. }
  676. nbr_som_couche.push_back(top_couche);
  677. int sum = 0;
  678. for(int i = 0; i < nbr_som_couche.size(); i++){
  679. sum += nbr_som_couche.at(i);
  680. }
  681. int reste = nbr_vertex - sum;
  682. /*std::cout<<"sum : "<<sum<<std::endl;
  683. std::cout<<"midel_couche : "<<midel_couche<<std::endl;
  684. std::cout<<"top_couche : "<<top_couche<<std::endl;
  685. std::cout<<"nbr_vertex_midel_couche : "<<nbr_vertex_midel_couche<<std::endl;
  686. std::cout<<"tmp : "<<tmp<<std::endl;
  687. std::cout<<"reste : "<<reste<<std::endl;
  688. for(int i =0; i < nbr_som_couche.size(); i++){
  689. std::cout<<nbr_som_couche.at(i)<<" ";
  690. }
  691. std::cout<<std::endl;*/
  692. while(reste != 0){
  693. for(int i = 1; i <nbr_som_couche.size(); i++){
  694. nbr_som_couche.at(i) += 1;
  695. reste --;
  696. if(reste == 0){
  697. break;
  698. }
  699. }
  700. }
  701. /*for(int i =0; i < nbr_som_couche.size(); i++){
  702. std::cout<<nbr_som_couche.at(i)<<" ";
  703. }
  704. std::cout<<std::endl;*/
  705. /*Génération du graphe*/
  706. std::vector<int> tab_couche_som;
  707. tab_couche_som.push_back(0);
  708. for(int i =1; i<nbr_som_couche.size(); i++){
  709. tab_couche_som.push_back(tab_couche_som.at(i-1)+nbr_som_couche.at(i));
  710. }
  711. /*for(int i =0; i < tab_couche_som.size(); i++){
  712. std::cout<<tab_couche_som.at(i)<<" ";
  713. }
  714. std::cout<<std::endl;*/
  715. int nbr_vois = nbr_v_max+2;
  716. int cpt = 0;
  717. for(int i = tab_couche_som.at(tab_couche_som.size()-2)+1; i <= tab_couche_som.at(tab_couche_som.size()-1); i++){
  718. std::vector<int> vertex_tmp;
  719. int rand = rand_fini(nbr_v_min,nbr_v_max+1);
  720. int neigh_cpt = 0;
  721. while(neigh_cpt != rand){
  722. int val;
  723. if(cpt<nbr_vois){
  724. val = rand_fini(tab_couche_som.at(tab_couche_som.size()-3)+cpt+1,tab_couche_som.at(tab_couche_som.size()-3)+cpt+1+nbr_vois);
  725. //std::cout<<"val1 : "<<val<<std::endl;
  726. }else if(cpt>nbr_vois && cpt<(tab_couche_som.at(tab_couche_som.size()-2)-tab_couche_som.at(tab_couche_som.size()-3)+1-nbr_vois)){
  727. val = rand_fini(tab_couche_som.at(tab_couche_som.size()-3)+cpt+1-nbr_vois,tab_couche_som.at(tab_couche_som.size()-3)+cpt+1+nbr_vois);
  728. //std::cout<<"val2 : "<<val<<std::endl;
  729. }else{
  730. val = rand_fini(tab_couche_som.at(tab_couche_som.size()-2)+1-2*nbr_vois,tab_couche_som.at(tab_couche_som.size()-2)+1);
  731. //std::cout<<"val3 : "<<val<<std::endl;
  732. }
  733. if(In_tab(vertex_tmp,val) != 1){
  734. boost::add_edge(Vertexs.at(i), Vertexs.at(val), EdgeProperties(1.), *go);
  735. vertex_tmp.push_back(val);
  736. neigh_cpt ++;
  737. }
  738. }
  739. cpt ++;
  740. }
  741. //std::cout<<"Passage !"<<std::endl;
  742. for(int j = 2; j < tab_couche_som.size()-1; j++){
  743. cpt = 0;
  744. for(int i = tab_couche_som.at(tab_couche_som.size()-1-j)+1; i <= tab_couche_som.at(tab_couche_som.size()-1-(j-1)); i++){
  745. std::vector<int> vertex_tmp;
  746. int rand = rand_fini(nbr_v_min,nbr_v_max+1);
  747. //std::cout<<"rand : "<<rand<<std::endl;
  748. int neigh_cpt = 0;
  749. while(neigh_cpt != rand){
  750. int val;
  751. if((tab_couche_som.at(tab_couche_som.size()-2-(j-1))-tab_couche_som.at(tab_couche_som.size()-2-j))>2*nbr_vois){
  752. if(cpt<nbr_vois){
  753. val = rand_fini(tab_couche_som.at(tab_couche_som.size()-2-j)+cpt+1,tab_couche_som.at(tab_couche_som.size()-2-j)+cpt+1+nbr_vois);
  754. //std::cout<<"val1 : "<<val<<std::endl;
  755. }else if(cpt>nbr_vois && cpt<(tab_couche_som.at(tab_couche_som.size()-2-(j-1))-tab_couche_som.at(tab_couche_som.size()-2-j)+1-nbr_vois)){
  756. val = rand_fini(tab_couche_som.at(tab_couche_som.size()-2-j)+cpt+1-nbr_vois,tab_couche_som.at(tab_couche_som.size()-2-j)+cpt+1+nbr_vois);
  757. //std::cout<<"val2 : "<<val<<std::endl;
  758. }else{
  759. if(2*nbr_vois<(tab_couche_som.at(tab_couche_som.size()-2-(j-1))-tab_couche_som.at(tab_couche_som.size()-2-j)+1)){
  760. val = rand_fini(tab_couche_som.at(tab_couche_som.size()-2-(j-1))+1-2*nbr_vois,tab_couche_som.at(tab_couche_som.size()-2-(j-1))+1);
  761. }else{
  762. val = rand_fini(tab_couche_som.at(tab_couche_som.size()-2-(j-1))+1-nbr_vois,tab_couche_som.at(tab_couche_som.size()-2-(j-1))+1);
  763. }
  764. //std::cout<<"val3 : "<<val<<std::endl;
  765. }
  766. }else{
  767. val = rand_fini(tab_couche_som.at(tab_couche_som.size()-2-j)+1,tab_couche_som.at(tab_couche_som.size()-2-(j-1))+1);
  768. }
  769. //int val = rand_fini(tab_couche_som.at(tab_couche_som.size()-2-j)+1,tab_couche_som.at(tab_couche_som.size()-2-(j-1))+1);
  770. if(In_tab(vertex_tmp,val) != 1){
  771. boost::add_edge(Vertexs.at(i), Vertexs.at(val), EdgeProperties(1.), *go);
  772. vertex_tmp.push_back(val);
  773. neigh_cpt ++;
  774. }
  775. }
  776. cpt ++;
  777. }
  778. }
  779. //std::cout<<"Passage2 !"<<std::endl;
  780. for(int i = tab_couche_som.at(0)+1; i <= tab_couche_som.at(1); i++){
  781. //int val = rand_fini(0,2);
  782. //if(val == 0){
  783. boost::add_edge(Vertexs.at(i), Vertexs.at(0), EdgeProperties(1.), *go);
  784. //}
  785. }
  786. //std::cout<<"Passage3 !"<<std::endl;
  787. std::vector < int > dg_in_vertex_list;
  788. std::vector <vertex_to> dg_vertex_list;
  789. OrientedGraph::vertex_iterator it_dg, end_dg;
  790. tie(it_dg, end_dg) = vertices(*go);
  791. for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
  792. dg_in_vertex_list.push_back(0);
  793. dg_vertex_list.push_back(*it_dg);
  794. }
  795. tie(it_dg, end_dg) = vertices(*go);
  796. for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
  797. OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
  798. tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_dg, *go);
  799. for (; neighbour_it != neighbour_end; ++neighbour_it) {
  800. uint index = 0;
  801. while (dg_vertex_list[index] != *neighbour_it) {
  802. ++index;
  803. }
  804. ++dg_in_vertex_list[index];
  805. }
  806. }
  807. for(uint i = 0; i<num_vertices(*go); i++){
  808. if(dg_in_vertex_list.at(i) == 0){
  809. (*go)[i] = VertexProperties(i, 1, TOP_PIXEL);
  810. }else{
  811. (*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
  812. }
  813. }
  814. }
  815. void build_graph_grid(OrientedGraph *go, int side, const std::vector<std::pair<int,int>> &vertex_selection, const Entiers &weight_vertex,const char *edge_weight, bool rec){
  816. int nbr_vertex = side*side;
  817. std::vector<vertex_to> Vertexs;
  818. for(int i =0; i<nbr_vertex; i++){
  819. vertex_to vo = boost::add_vertex(*go);
  820. Vertexs.push_back(vo);
  821. }
  822. if(rec == true){
  823. std::ofstream fichier (edge_weight, std::ios::out);
  824. for(int i = 0; i<side; i++){
  825. for(int j = 0; j<side-1; j++){
  826. boost::add_edge(i*side+j, i*side+j+1,EdgeProperties(1), *go);
  827. fichier<<i*side+j<<" "<<i*side+j+1<<" "<<1<<" "<<std::endl;
  828. }
  829. }
  830. for(int i = 0; i<side-1; i++){
  831. for(int j = 0; j<side; j++){
  832. boost::add_edge(i*side+j, (i+1)*side+j,EdgeProperties(1), *go);
  833. fichier<<i*side+j<<" "<<(i+1)*side+j<<" "<<1<<" "<<std::endl;
  834. }
  835. }
  836. fichier.close();
  837. }else{
  838. for(int i = 0; i<side; i++){
  839. for(int j = 0; j<side-1; j++){
  840. boost::add_edge(i*side+j, i*side+j+1,EdgeProperties(1), *go);
  841. }
  842. }
  843. for(int i = 0; i<side-1; i++){
  844. for(int j = 0; j<side; j++){
  845. boost::add_edge(i*side+j, (i+1)*side+j,EdgeProperties(1), *go);
  846. }
  847. }
  848. }
  849. (*go)[0] = VertexProperties(0, 1, TOP_PIXEL);
  850. for(uint i = 1; i<num_vertices(*go); i++){
  851. (*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
  852. }
  853. for(int ind=0; ind<vertex_selection.size(); ind++){
  854. for(int ind_i = vertex_selection.at(ind).first; ind_i<vertex_selection.at(ind).second+1; ind_i++){
  855. if(ind_i != 0)
  856. (*go)[ind_i] = VertexProperties(ind_i, weight_vertex.at(ind), NORMAL_PIXEL);
  857. else
  858. (*go)[ind_i] = VertexProperties(ind_i, weight_vertex.at(ind), TOP_PIXEL);
  859. }
  860. }
  861. if(rec == false){
  862. std::ifstream fichier (edge_weight, std::ios::in);
  863. if(fichier){
  864. bool found;
  865. edge_to e1;
  866. int edge1, edge2;
  867. double edge_weight;
  868. int lines = std::count(std::istreambuf_iterator<char>( fichier ),std::istreambuf_iterator<char>(),'\n' );
  869. //std::cout<<lines<<std::endl;
  870. int cpt =0;
  871. int length;
  872. fichier.seekg(0, std::ios::beg);
  873. while(cpt < lines){
  874. fichier >> edge1 >> edge2 >> edge_weight;
  875. tie(e1,found)=edge(vertex(edge1,*go),vertex(edge2,*go),*go);
  876. (*go)[e1] = EdgeProperties(edge_weight);
  877. //std::cout<<edge1<<" "<<edge2<<" "<<edge_weight<<std::endl;
  878. length = fichier.tellg();
  879. fichier.seekg(length+1, std::ios::beg);
  880. cpt++;
  881. }
  882. }else{
  883. std::cerr<<"Bugggggg du fichier txt !!!! "<<std::endl;
  884. }
  885. fichier.close();
  886. }
  887. }
  888. /*Vérification de la pondération + vérification des poids de la contraction + vérification de la structure de contraction*/
  889. } } } // namespace paradevs tests boost_graph