Bladeren bron

Add plot example and refactor partitioning methods and graph definitions

Eric Ramat 9 jaren geleden
bovenliggende
commit
7fa7c35072

+ 1 - 0
src/tests/CMakeLists.txt

@@ -6,3 +6,4 @@ ADD_SUBDIRECTORY(mixed)
 ADD_SUBDIRECTORY(mpi)
 ADD_SUBDIRECTORY(multithreading)
 ADD_SUBDIRECTORY(pdevs)
+ADD_SUBDIRECTORY(plot)

+ 8 - 5
src/tests/boost_graph/CMakeLists.txt

@@ -10,19 +10,22 @@ LINK_DIRECTORIES(
   ${LIBXML_LIBRARY_DIR})
 
 # graph tests
-ADD_EXECUTABLE(graph-tests graph_builder.hpp graph_generator.hpp graph_defs.hpp graph_manager.hpp
-  graph_partitioning.hpp tests.cpp models.hpp)
+ADD_EXECUTABLE(graph-tests graph_builder.hpp graph_generator.hpp
+  graph_defs.hpp graph_manager.hpp graph_partitioning.hpp tests.cpp models.hpp
+  partitioning/utils.hpp partitioning/gggp.hpp partitioning/graph_build.hpp)
 
 # file generator
-ADD_EXECUTABLE(file-generator graph_generator.hpp graph_defs.hpp graph_partitioning.hpp file_generator.cpp)
+ADD_EXECUTABLE(file-generator graph_generator.hpp graph_defs.hpp
+  graph_partitioning.hpp file_generator.cpp
+  partitioning/utils.hpp partitioning/gggp.hpp partitioning/graph_build.hpp)
 
-TARGET_LINK_LIBRARIES(graph-tests partitioning
+TARGET_LINK_LIBRARIES(graph-tests
   ${Boost_LIBRARIES}
   ${GLIBMM_LIBRARIES}
   ${LIBXML_LIBRARIES}
   ${GTHREAD_LIBRARIES})
 
-TARGET_LINK_LIBRARIES(file-generator partitioning
+TARGET_LINK_LIBRARIES(file-generator
   ${Boost_LIBRARIES}
   ${GLIBMM_LIBRARIES}
   ${LIBXML_LIBRARIES}

+ 3 - 2
src/tests/boost_graph/file_generator.cpp

@@ -28,6 +28,7 @@
 #include <fstream>
 #include <boost/timer.hpp>
 
+#include <tests/boost_graph/graph_defs.hpp>
 #include <tests/boost_graph/graph_generator.hpp>
 #include <tests/boost_graph/graph_partitioning.hpp>
 
@@ -68,7 +69,7 @@ int main()
 	//ArtificialGraphGenerator generator(38);
 
 	ParcelGraphGenerator generator(10000, "mono");
-	std::cout << "Duration : " << t.elapsed() << " seconds" << std::endl;
+	// std::cout << "Duration : " << t.elapsed() << " seconds" << std::endl;
 
 	OrientedGraph::vertex_iterator vertexIt, vertexEnd;
 
@@ -123,7 +124,7 @@ int main()
     graph_builder.build(graphs, input_edges, output_edges,
                         parent_connections);
 
-    std::cout << "Duration : " << t.elapsed() << " seconds" << std::endl;
+    // std::cout << "Duration : " << t.elapsed() << " seconds" << std::endl;
 
     /*std::vector<const char*> name;
     name.push_back("../../sortie_graphe/Tests/Graphes/Multiniveau/txt/partie_0.txt");

+ 0 - 1
src/tests/boost_graph/graph_builder.hpp

@@ -27,7 +27,6 @@
 #ifndef __TESTS_BOOST_GRAPH_GRAPH_BUILDER_HPP
 #define __TESTS_BOOST_GRAPH_GRAPH_BUILDER_HPP 1
 
-#include <tests/boost_graph/graph_defs.hpp>
 #include <tests/boost_graph/partitioning/graph_build.hpp>
 
 namespace paradevs { namespace tests { namespace boost_graph {

+ 17 - 0
src/tests/boost_graph/graph_defs.hpp

@@ -43,6 +43,10 @@ struct VertexProperties
     VertexProperties(int index, double weight, int type) :
         _index(index), _weight(weight), _type(type)
     { }
+
+    VertexProperties(const VertexProperties& vp) :
+        _index(vp._index), _weight(vp._weight), _type(vp._type)
+    { }
 };
 
 struct EdgeProperties
@@ -51,6 +55,7 @@ struct EdgeProperties
 
     EdgeProperties() : _weight(0)
     { }
+
     EdgeProperties(double weight) : _weight(weight)
     { }
 };
@@ -61,6 +66,18 @@ typedef boost::adjacency_list < boost::vecS, boost::vecS,
                                 EdgeProperties > OrientedGraph;
 typedef std::vector < OrientedGraph > OrientedGraphs;
 
+typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS,
+                                VertexProperties,
+                                EdgeProperties> UnorientedGraph;
+
+typedef std::vector < UnorientedGraph* > Base_Graph;
+
+typedef boost::graph_traits < UnorientedGraph >::vertex_descriptor vertex_t;
+typedef boost::graph_traits < UnorientedGraph >::edge_descriptor edge_t;
+
+typedef OrientedGraph::vertex_descriptor vertex_to;
+typedef OrientedGraph::edge_descriptor edge_to;
+
 typedef std::pair < int, int > Edge;
 typedef std::vector < Edge > Edges;
 typedef Edges OutputEdges;

+ 0 - 1
src/tests/boost_graph/graph_generator.hpp

@@ -27,7 +27,6 @@
 #ifndef __TESTS_BOOST_GRAPH_GRAPH_GENERATOR_HPP
 #define __TESTS_BOOST_GRAPH_GRAPH_GENERATOR_HPP 1
 
-#include <tests/boost_graph/graph_defs.hpp>
 #include <tests/boost_graph/partitioning/defs.hpp>
 #include <tests/boost_graph/partitioning/utils.hpp>
 #include <tests/boost_graph/partitioning/graph_build.hpp>

+ 0 - 1
src/tests/boost_graph/graph_manager.hpp

@@ -28,7 +28,6 @@
 #define __TESTS_BOOST_GRAPH_GRAPH_MANAGER_HPP 1
 
 #include <paradevs/common/scheduler/HeapScheduler.hpp>
-// #include <paradevs/common/scheduler/VectorScheduler.hpp>
 
 #include <paradevs/kernel/pdevs/Coordinator.hpp>
 #include <paradevs/kernel/pdevs/GraphManager.hpp>

+ 0 - 3
src/tests/boost_graph/graph_partitioning.hpp

@@ -27,15 +27,12 @@
 #ifndef __TESTS_BOOST_GRAPH_GRAPH_PARTITIONING_HPP
 #define __TESTS_BOOST_GRAPH_GRAPH_PARTITIONING_HPP 1
 
-#include <tests/boost_graph/graph_defs.hpp>
 #include <tests/boost_graph/graph_generator.hpp>
 #include <tests/boost_graph/partitioning/graph_build.hpp>
 #include <tests/boost_graph/partitioning/gggp.hpp>
 
 #include <boost/graph/copy.hpp>
 
-#include <iostream>
-
 namespace paradevs { namespace tests { namespace boost_graph {
 
 class PartitioningGraphBuilder

+ 11 - 10
src/tests/boost_graph/partitioning/CMakeLists.txt

@@ -9,21 +9,22 @@ LINK_DIRECTORIES(
   ${GLIBMM_LIBRARY_DIRS}
   ${LIBXML_LIBRARY_DIR})
 
-SET(PARTITIONING_HPP utils.hpp gggp.hpp graph_build.hpp) 
+SET(PARTITIONING_HPP utils.hpp gggp.hpp graph_build.hpp)
 
-SET(PARTITIONING_CPP utils.cpp gggp.cpp graph_build.cpp)
+SET(PARTITIONING_CPP )
 
-ADD_LIBRARY(partitioning SHARED ${PARTITIONING_HPP};${PARTITIONING_CPP})
+#ADD_LIBRARY(partitioning SHARED ${PARTITIONING_HPP};${PARTITIONING_CPP})
 
-TARGET_LINK_LIBRARIES(partitioning
-  ${Boost_LIBRARIES}
-  ${GLIBMM_LIBRARIES}
-  ${LIBXML_LIBRARIES}
-  ${GTHREAD_LIBRARIES})
+#TARGET_LINK_LIBRARIES(partitioning
+#  ${Boost_LIBRARIES}
+#  ${GLIBMM_LIBRARIES}
+#  ${LIBXML_LIBRARIES}
+#  ${GTHREAD_LIBRARIES})
 
-ADD_EXECUTABLE(partitioning-tests main.cpp)
+ADD_EXECUTABLE(partitioning-tests main.cpp
+  ${PARTITIONING_HPP};${PARTITIONING_CPP})
 
-TARGET_LINK_LIBRARIES(partitioning-tests partitioning
+TARGET_LINK_LIBRARIES(partitioning-tests #partitioning
   ${Boost_LIBRARIES}
   ${GLIBMM_LIBRARIES}
   ${LIBXML_LIBRARIES}

+ 0 - 14
src/tests/boost_graph/partitioning/defs.hpp

@@ -32,8 +32,6 @@
 
 #include <boost/graph/adjacency_list.hpp>
 
-#include <tests/boost_graph/graph_defs.hpp>
-
 namespace paradevs { namespace tests { namespace boost_graph {
 
 typedef unsigned int uint;
@@ -45,18 +43,6 @@ typedef std::vector < EntiersEntiers > EntiersEntiersEntiers;
 typedef std::list < int > List;
 typedef std::list < EntiersEntiers* > ListEntiersEntiers;
 
-typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS,
-                                VertexProperties,
-                                EdgeProperties> UnorientedGraph;
-
-typedef std::vector < UnorientedGraph* > Base_Graph;
-
-typedef boost::graph_traits < UnorientedGraph >::vertex_descriptor vertex_t;
-typedef boost::graph_traits < UnorientedGraph >::edge_descriptor edge_t;
-
-typedef OrientedGraph::vertex_descriptor vertex_to;
-typedef OrientedGraph::edge_descriptor edge_to;
-
 template < class G >
 struct VertexAndEdgeListGraphConcept
 {

+ 0 - 1249
src/tests/boost_graph/partitioning/gggp.cpp

@@ -1,1249 +0,0 @@
-/**
- * @file tests/boost_graph/partitioning/gggp.cpp
- * @author The PARADEVS Development Team
- * See the AUTHORS or Authors.txt file
- */
-
-/*
- * PARADEVS - the multimodeling and simulation environment
- * This file is a part of the PARADEVS environment
- *
- * Copyright (C) 2013-2015 ULCO http://www.univ-litoral.fr
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <tests/boost_graph/partitioning/gggp.hpp>
-#include <boost/timer.hpp>
-#include <algorithm>
-#include <iostream>
-#include <fstream>
-
-namespace paradevs { namespace tests { namespace boost_graph {
-
-extern UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
-extern UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
-
-extern OrientedGraph::vertex_iterator vertexIto, vertexEndo;
-extern OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
-
-void ggp(UnorientedGraph *g, Entiers *sommetsSource,
-               Entiers *sommetsDestination, EntiersEntiers &Partition, int rand, int &index_partition, int distance)
-{
-    Entiers sommets_adj;
-    if(sommetsSource->size()==1){
-        Entiers tailles;
-        for(uint i=0;i<Partition.size();i++){
-            tailles.push_back(Partition.at(i)->size());
-        }
-        uint tmp=*max_element(tailles.begin(),tailles.end());
-        for(uint i=0; i<Partition.size();i++){
-            if(Partition.at(i)->size() == tmp)
-            {
-				sommetsSource->clear();
-				for(uint id = 0; id < Partition.at(i)->size();id++){
-					sommetsSource->push_back(Partition.at(i)->at(id));
-				}
-				index_partition = i;
-				if(distance != -1){
-					ggp(g, sommetsSource, sommetsDestination, Partition,
-						Partition.at(i)->at(rand_fini(0,Partition.at(i)->size())),
-						index_partition, distance);
-				}else{
-					ggp(g, sommetsSource, sommetsDestination, Partition,
-						rand_fini(0,Partition.at(i)->size()),
-						index_partition, distance);
-				}
-                return;
-            }
-        }
-    }
-
-    double poids_max=0;
-    for(uint i=0;i<sommetsSource->size();i++){
-        poids_max+=(*g)[sommetsSource->at(i)]._weight;
-    }
-    poids_max/=2.;
-
-	double poids;
-    if(distance == -1){
-		poids=(*g)[sommetsSource->at(rand)]._weight;
-		sommetsDestination->push_back(sommetsSource->at(rand));
-		sommetsSource->erase(sommetsSource->begin() + rand);
-
-	}else{
-		poids=(*g)[rand]._weight;
-		sommetsDestination->push_back(rand);
-		suprim_val(*sommetsSource,rand);
-	}
-
-    uint cpt = 0;
-    while(poids<poids_max && sommetsSource->size()>1)
-    {
-        if(cpt<sommetsDestination->size()){
-            adjacence_ggp(sommetsDestination->at(cpt),sommets_adj,g);
-		} else{
-            int val=rand_fini(0,sommetsSource->size()-1);
-            sommetsDestination->push_back(sommetsSource->at(val));
-            sommetsSource->erase(sommetsSource->begin() + val);
-            adjacence_ggp(sommetsDestination->at(cpt),sommets_adj,g);
-        }
-        if(sommets_adj.size() == 0)
-        {
-            sort(sommetsDestination->begin(), sommetsDestination->end());
-            return;
-        }
-        else{
-            for(uint i =0; i<sommets_adj.size(); i++){
-                if(In_tab(*sommetsDestination,sommets_adj.at(i)) != 1 && sommetsSource->size()!=1){
-                    sommetsDestination->push_back(sommets_adj.at(i));
-                    poids+=(*g)[sommets_adj.at(i)]._weight;
-                    suprim_val(*sommetsSource, sommets_adj[i]);
-                }
-                else if(poids>=poids_max || sommetsSource->size() == 1){
-					sort(sommetsDestination->begin(), sommetsDestination->end());
-					return;
-				}
-            }
-
-            /*std::cout<<"Sommets_source :"<<std::endl;
-            for(uint i =0; i<sommetsSource->size();i++){
-                std::cout<<sommetsSource->at(i)<<",";
-            }
-            std::cout<<std::endl;
-            std::cout<<"Sommets_destination :"<<std::endl;
-            for(uint i =0; i<sommetsDestination->size();i++){
-                std::cout<<sommetsDestination->at(i)<<",";
-            }
-            std::cout<<std::endl;*/
-        }
-        sommets_adj.clear();
-        cpt++;
-
-    }
-
-    sort(sommetsDestination->begin(), sommetsDestination->end());
-}
-
-void Transfert_vertex_bissection(UnorientedGraph *g, Entiers *sommetsSource, Entiers *sommetsDestination, Entiers &sommets_adj, const std::string &name, double &poids, double &cut){
-	std::vector<double> sommets_cut;
-	sort(sommets_adj.begin(), sommets_adj.end());
-	for(uint i=0;i<sommets_adj.size();i++)
-	{
-		double tmp_cut = cut;
-		if(name == "cut"){
-			sommets_cut.push_back(modif_Cout_coupe(*sommetsDestination,sommets_adj.at(i),tmp_cut,g));
-		}else if(name == "ratio"){
-			//std::cout<<"adj : "<<(*g)[sommets_adj.at(i)]._index<<" cut = "<<Modif_ratio_cut(g, sommetsSource, sommetsDestination, sommets_adj.at(i), tmp_cut)<<std::endl;
-			sommets_cut.push_back(Modif_ratio_cut(g, sommetsSource, sommetsDestination, sommets_adj.at(i), tmp_cut));
-		}
-	}
-
-	cut = *min_element(sommets_cut.begin(),sommets_cut.end());
-	//std::cout<<"*** Passage 3 cut ***** : "<<cut<<std::endl;
-	//std::cout<<"Meilleur voisin : "<<(*g)[sommets_adj.at(recherche_val_double(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end())))]._index<<std::endl;
-	sommetsDestination->push_back(sommets_adj[recherche_val_double(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
-	//std::cout<<"*** Passage 3 cuta ***"<<std::endl;
-	poids+=(*g)[sommets_adj[recherche_val_double(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]]._weight;
-	//std::cout<<"*** Passage 3 cutb ***"<<std::endl;
-	suprim_val(*sommetsSource, sommets_adj[recherche_val_double(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
-	suprim_val(sommets_adj, sommets_adj[recherche_val_double(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
-
-	//std::cout<<"*** Passage 3 fin ***"<<std::endl;
-
-}
-
-void Tirage_transfert_vertex_bissection(UnorientedGraph *g, Entiers *sommetsSource, Entiers *sommetsDestination, const std::string &name, double &poids, double &cut){
-	double diff = -100.;
-	uint tmp_tir;
-	while(diff != 0){
-		tmp_tir = sommetsSource->at(rand_fini(0,sommetsSource->size()));
-		diff = Diff_cut_ratio_bissection(g, sommetsSource, tmp_tir, name);
-	}
-	poids += (*g)[tmp_tir]._weight;
-	if(name == "cut"){
-		cut = modif_Cout_coupe(*sommetsDestination,tmp_tir,cut,g);
-	}else{
-		cut = Modif_ratio_cut(g, sommetsSource, sommetsDestination, tmp_tir, cut);
-	}
-	sommetsDestination->push_back(tmp_tir);
-	suprim_val(*sommetsSource,tmp_tir);
-}
-
-bool Best_transfert_vertex_bissection(UnorientedGraph *g, Entiers *sommetsSource, Entiers *sommetsDestination, Entiers &sommets_adj,
-									  const std::string &name, double &poids, double poids_max, double PC, int stop, int &cpt, double &cut){
-    Liste_Voisin(*sommetsDestination,sommets_adj,*g);
-    //sort(sommets_adj.begin(), sommets_adj.end());
-	if((sommets_adj.size() == 0) & (cpt<stop) & (sommetsSource->size()>1))
-	{
-		cpt++;
-		//std::cout<<"*** Passage 1 ***"<<std::endl;
-		if(poids < (poids_max - poids_max*PC/100)){
-			//std::cout<<"*** Passage 1a ***"<<std::endl;
-			Tirage_transfert_vertex_bissection(g, sommetsSource, sommetsDestination, name, poids, cut);
-			if((poids < (poids_max - poids_max*PC/100)) & (sommetsSource->size()>1)){
-				Best_transfert_vertex_bissection(g, sommetsSource, sommetsDestination, sommets_adj,
-												name, poids, poids_max, PC, stop, cpt, cut);
-			}else{
-				//std::cout<<"*** Passage 1ac ***"<<std::endl;
-				return true;
-			}
-		}else{
-			//std::cout<<"*** Passage 1b ***"<<std::endl;
-			return true;
-		}
-
-	}
-	else if ((sommets_adj.size() == 0) & (cpt>=stop)){
-		//std::cout<<"*** Passage 2 ***"<<std::endl;
-		return true;
-	}else if (sommetsSource->size()==1){
-		//std::cout<<"*** Passage 4 ***"<<std::endl;
-		return true;
-	}else{
-		//std::cout<<"*** Passage 3 *** : "<<cut<<std::endl;
-		Transfert_vertex_bissection(g, sommetsSource, sommetsDestination, sommets_adj, name, poids, cut);
-		return false;
-	}
-}
-
-void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource, Entiers *sommetsDestination,
-				EntiersEntiers &Partition, int rand, int &index_partition, const std::string &name, int distance)
-{
-    Entiers sommets_adj;
-    double poids_max = 0;
-    double poids, cut;
-
-    if(sommetsSource->size()==1){
-        Entiers tailles;
-        for(uint i=0;i<Partition.size();i++){
-            tailles.push_back(Partition.at(i)->size());
-        }
-        uint tmp=*max_element(tailles.begin(),tailles.end());
-        for(uint i=0; i<Partition.size();i++){
-            if(Partition.at(i)->size()==tmp)
-            {
-				sommetsSource->clear();
-				for(uint id = 0; id < Partition.at(i)->size();id++){
-					sommetsSource->push_back(Partition.at(i)->at(id));
-				}
-				index_partition = i;
-				if(distance != -1)
-					gggp_pond(g,sommetsSource,sommetsDestination,Partition,
-						Partition.at(i)->at(rand_fini(0,Partition.at(i)->size())),
-						index_partition, name, distance);
-				else
-					gggp_pond(g, sommetsSource, sommetsDestination,
-						Partition, rand_fini(0,Partition.at(i)->size()),
-						index_partition, name ,distance);
-                return;
-            }
-        }
-    }
-
-    for(uint i=0;i<sommetsSource->size();i++){
-        poids_max+=(*g)[sommetsSource->at(i)]._weight;
-    }
-    poids_max/=2.;
-
-    if(distance == -1){
-		poids=(*g)[sommetsSource->at(rand)]._weight;
-		if(name == "cut"){
-			cut = Degree(*g,sommetsSource->at(rand));
-		}else if(name == "ratio"){
-			cut = Degree(*g,sommetsSource->at(rand));
-			double tmp_cut = cut/2./(*g)[sommetsSource->at(rand)]._weight
-				   + cut/2./(Cluster_Weight(*g,*sommetsSource)-(*g)[sommetsSource->at(rand)]._weight);
-			cut = tmp_cut;
-		}
-		sommetsDestination->push_back(sommetsSource->at(rand));
-		sommetsSource->erase(sommetsSource->begin() + rand);
-	}else{
-		poids=(*g)[rand]._weight;
-		cut = Degree(*g,rand);
-		if(name == "ratio"){
-			double tmp_cut = cut/2./(*g)[rand]._weight + cut/2./(Cluster_Weight(*g,*sommetsSource)-(*g)[rand]._weight);
-			cut = tmp_cut;
-		}
-		sommetsDestination->push_back(rand);
-		suprim_val(*sommetsSource,rand);
-	}
-
-    while(poids<poids_max && sommetsSource->size()>1)
-    {
-		int cpt = 0;
-        bool next = Best_transfert_vertex_bissection(g, sommetsSource, sommetsDestination, sommets_adj,
-													name, poids, poids_max, 20, 2, cpt, cut);
-		if(next == true){
-			sort(sommetsDestination->begin(), sommetsDestination->end());
-			return;
-		}
-    }
-    sort(sommetsDestination->begin(), sommetsDestination->end());
-}
-
-/*Liste_Voisin(*sommetsDestination,sommets_adj,*g);
-if(sommets_adj.size()==0)
-{
-	std::cout<<"*** Passage ***"<<std::endl;
-	if(poids < (poids_max - poids_max*40/100)){
-		Tirage_transfert_vertex_bissection(g, sommetsSource, sommetsDestination, name, poids);
-
-		Liste_Voisin(*sommetsDestination,sommets_adj,*g);
-		if(sommets_adj.size() != 0){
-			Transfert_vertex_bissection(g, sommetsSource, sommetsDestination, sommets_adj, name, poids);
-		}else{
-			sort(sommetsDestination->begin(), sommetsDestination->end());
-			return;
-		}
-	}else{
-		sort(sommetsDestination->begin(), sommetsDestination->end());
-		return;
-	}
-
-}
-else{
-	Transfert_vertex_bissection(g, sommetsSource, sommetsDestination, sommets_adj, name, poids);
-}*/
-
-
-void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
-             const std::string &nom_cut, int nbr_tirage,
-             const std::string &nom_strat, bool rec, int distance)
-{
-
-	UnorientedGraph copy_graph;
-	boost::copy_graph(*g,copy_graph);
-	int cpt = 0;
-
-	for(int i = 0; i<floor(log(nbr_parties)/log(2)); i++){
-		for(int j = 0; j< pow(2,i);j++) {
-			if(distance == -1){
-				if(nbr_tirage != 0)
-					Optimisation_method_neighbour(g,part,j,nbr_tirage, nom_cut, nom_strat);
-				else
-					Optimisation_method_neighbour_minweight(g,part,j, nom_cut, nom_strat);
-			}else
-				Optimisation_method_neighbour_distance(g,part,j,nbr_tirage, distance, nom_cut, nom_strat);
-
-			if(rec){
-				std::vector<std::string> color;
-				color.push_back("[color=blue2, fontcolor=blue2];");
-				color.push_back("[color=red, fontcolor=red];");
-				color.push_back("[color=green, fontcolor=green];");
-				color.push_back("[color=turquoise, fontcolor=turquoise];");
-				color.push_back("[color=saddlebrown, fontcolor=saddlebrown];");
-				color.push_back("[color=indigo, fontcolor=indigo];");
-				color.push_back("[color=yellow, fontcolor=yellow2];");
-				color.push_back("[color=orange, fontcolor=orange];");
-				color.push_back("[color=olivedrab, fontcolor=olivedrab];");
-				color.push_back("[color=gold, fontcolor=gold];");
-				color.push_back("[color=slateblue2, fontcolor=slateblue2];");
-				color.push_back("[color=dimgrey, fontcolor=dimgrey];");
-				color.push_back("[color=cyan, fontcolor=cyan];");
-				color.push_back("[color=purple1, fontcolor=purpule1];");
-				color.push_back("[color=crimson, fontcolor=crimson];");
-				color.push_back("[color=black, fontcolor=black];");
-
-	    		std::vector<char* > nom;
-				char * tmp_nom1 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_1.txt";
-				nom.push_back(tmp_nom1);
-				char * tmp_nom2 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_2.txt";
-				nom.push_back(tmp_nom2);
-				char * tmp_nom3 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_3.txt";
-				nom.push_back(tmp_nom3);
-				char * tmp_nom4 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_4.txt";
-				nom.push_back(tmp_nom4);
-				char * tmp_nom5 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_5.txt";
-				nom.push_back(tmp_nom5);
-				char * tmp_nom6 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_6.txt";
-				nom.push_back(tmp_nom6);
-				char * tmp_nom7 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_7.txt";
-				nom.push_back(tmp_nom7);
-				char * tmp_nom8 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_8.txt";
-				nom.push_back(tmp_nom8);
-				char * tmp_nom9 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_9.txt";
-				nom.push_back(tmp_nom9);
-				char * tmp_nom10 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_10.txt";
-				nom.push_back(tmp_nom10);
-
-	    		std::ofstream GRAPH2 (nom.at(cpt), std::ios::out);
-				GRAPH2<<"graph G {"<<std::endl;
-				tie(vertexIt, vertexEnd) = vertices(copy_graph);
-				for (; vertexIt != vertexEnd; ++vertexIt) {
-					GRAPH2<<(copy_graph)[*vertexIt]._index<<" -- {";
-					tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
-	    			copy_graph);
-					for (; neighbourIt != neighbourEnd; ++neighbourIt){
-						if((copy_graph)[*neighbourIt]._index>(copy_graph)[*vertexIt]._index)
-							GRAPH2<<(copy_graph)[*neighbourIt]._index<<";";
-					}
-					GRAPH2<<"}"<<std::endl;
-				}
-
-				for(uint k=0; k<part.size(); k++){
-					for(uint t=0; t<part.at(k)->size(); t++)
-					{
-						GRAPH2<<(copy_graph)[part.at(k)->at(t)]._index<<color.at(k)<<std::endl;
-					}
-				}
-
-				GRAPH2<<"}";
-				GRAPH2.close();
-			}
-
-			cpt ++;
-		}
-    }
-}
-
-void bissectionRec(UnorientedGraph *g, EntiersEntiers &Partition,
-                   int nbr_parties, const std::string &nom_cut,
-                   int nbr_tirage, const std::string &nom_strat,
-                   int distance)
-{
-    if((nbr_parties&(nbr_parties-1)) == 0)
-        Iter_2l(Partition, nbr_parties, g, nom_cut, nbr_tirage,
-						   nom_strat, false, distance);
-    else{
-        int puissance_2=0;
-
-        Entiers tailles;
-
-        while(pow(2,puissance_2)<nbr_parties)
-            puissance_2++;
-
-        Iter_2l(Partition, pow(2,puissance_2-1), g,
-				nom_cut, nbr_tirage, nom_strat, false, distance);
-
-        for(unsigned int i = 0; i< Partition.size() -1 ; i++)
-        {
-            for(EntiersEntiers::iterator it1 = Partition.begin() + i ;
-				it1!=Partition.end(); it1++)
-            {
-                if((*it1)->size() > Partition.at(i)->size())
-                    Partition.at(i)->swap(**it1);
-            }
-        }
-
-        for(int j = 0; j<nbr_parties-pow(2,puissance_2-1);j++)
-        {
-			if(distance == -1){
-				if(nbr_tirage != 0){
-					Optimisation_method_neighbour(g, Partition, j,
-												  nbr_tirage, nom_cut,
-												  nom_strat);
-				}else{
-					Optimisation_method_neighbour_degree(g, Partition, j,
-												  nom_cut, nom_strat);
-				}
-			}else{
-				Optimisation_method_neighbour_distance(g, Partition, j,
-												  nbr_tirage, distance,
-												  nom_cut, nom_strat);
-			}
-        }
-    }
-}
-
-/**
- * Fonction réalisant un partitionnement pseudo aléatoire suivant un voisinage.
- * @param *g : adresse d'un graphe de type boost graphe undirected
- * @param Partition : vecteur contenant des vecteurs d'entiers [tableau contenant les parties de la partition]
- * @param nbr_partie : entier correspondant au nombre de parties voulues pour la partition
- * @return
- */
-
-void Pseudo_random_partitioning(UnorientedGraph *g, EntiersEntiers &Partition,
-                                uint nbr_parties)
-{
-    /*
-     * Principe : distribution des sommets de la première partie en plusieurs autres parties
-     * Le partitionnement étant pseudo aléatoire il n'y a pas de contrainte stricte sur le nombre
-     * de sommets par partie
-     */
-
-
-    uint size = Partition.at(0)->size();
-    uint cpt_sommets=1;
-    int val;
-    uint cpt;
-
-    if(nbr_parties==size){
-        for(uint i = 0; i < nbr_parties;i++){
-            if(Partition.at(0)->size()!=1)
-            {
-                val=rand_fini(0,Partition.at(0)->size()-1);//tirage aléatoire d'un sommets
-            }
-            else
-                val=0;
-
-            int vertex = Partition.at(0)->at(val);
-            Entiers *part = new Entiers();
-            part->push_back(vertex);// ajout du sommet tiré
-            suprim_val(*Partition.at(0),vertex);//suppression du sommet dans la premiere partie
-
-        }
-    }
-    /*
-     * Boucle sur le nombre de partie à réaliser
-     */
-    for(uint i = 0; i < nbr_parties-1;i++){
-        if(Partition.at(0)->size()!=1)
-        {
-            val=rand_fini(0,Partition.at(0)->size()-1);//tirage aléatoire d'un sommets
-        }
-        else
-            val=0;
-        int vertex = Partition.at(0)->at(val);
-        /*
-         * Initialisation d'un pointeur sur un vecteur d'entier, dans notre cas
-         * la n+1 ième partie de la partition
-         */
-        Entiers *part = new Entiers();
-        part->push_back(vertex);// ajout du sommet tiré
-        suprim_val(*Partition.at(0),vertex);//suppression du sommet dans la premiere partie
-        cpt=1;
-
-        /*
-         * Pour chaque element de la nouvelle partie faire
-         */
-        for(uint j = 0; j<part->size();j++){
-            /*
-             * Détermination des voisins de chacun des sommets de cette nouvelle
-             * partie et ajoue de ce voisin si celui-ci est présent dans la première partie (Partition[0])
-             */
-            tie(neighbourIt, neighbourEnd) = adjacent_vertices(part->at(j),*g);
-            for (; neighbourIt != neighbourEnd; ++neighbourIt){
-                if(In_tab(*Partition.at(0),*neighbourIt)==1){
-                    // std::cout<<"le voisin déplacé est : "<<*neighbourIt<<std::endl;
-                    part->push_back(*neighbourIt);
-                    cpt_sommets++;
-                    suprim_val(*Partition.at(0),*neighbourIt);
-                    cpt++;
-                }
-                /*
-                 * Si le nombre moyen de sommets est atteind dans la partie on sort de la boucle des voisins
-                 * Même chose si l'on a rencontré le nombre total de sommets
-                 */
-                if(cpt==(size/nbr_parties)+1)
-                    break;
-                if(cpt_sommets==size)
-                    break;
-            }
-
-            /*
-             * Même chose
-             */
-            if(cpt==(size/nbr_parties)+1)
-                break;
-            if(cpt_sommets==size)
-                break;
-        }
-        Partition.push_back(part);// ajoue de la nouvelle partie à la partition
-        if(cpt_sommets==size)
-            break;
-    }
-}
-
-EntiersEntiers Random_equal_weight_partitioning(UnorientedGraph *g,
-                                uint parts_number)
-{
-	EntiersEntiers Partition;
-	Entiers random_order =  Random_Sort_Vector(num_vertices(*g));
-	uint cpt = 0;
-
-	for(uint j = 0 ; j < parts_number ; j++){
-		Entiers *part = new Entiers();
-		Partition.push_back(part);
-	}
-
-	for(uint id = 0; id < random_order.size(); id++){
-		Partition.at(cpt)->push_back(random_order.at(id));
-		cpt++;
-		if(cpt == parts_number)
-			cpt = 0;
-	}
-
-	for(uint i = 0 ; i < Partition.size() ; i++){
-		sort(Partition.at(i)->begin(),Partition.at(i)->end());
-	}
-
-	return Partition;
-}
-
-EntiersEntiers Random_partitioning(UnorientedGraph *g,
-                                uint parts_number)
-{
-	EntiersEntiers Partition;
-	uint nbr_vertices = num_vertices(*g);
-	Entiers random_order =  Random_Sort_Vector(nbr_vertices);
-	uint cpt = 0;
-
-	std::vector<int> taille;
-
-	int tmp_size = nbr_vertices;
-	for(uint i = 0; i < parts_number - 1; i++){
-		int t1;
-		if(parts_number < 10){
-			if(floor(tmp_size*0.5/10) != 0)
-				t1 = rand_fini(floor(tmp_size*0.5/100), floor(tmp_size*(60-10*i/2)/100));
-			else
-				t1 = rand_fini(1, floor(tmp_size*(60-10*i/2)/100));
-		}else{
-			if(floor(tmp_size*0.5/100) != 0)
-				t1 = rand_fini(floor(tmp_size*0.5/100), floor(tmp_size*(60-10*i/4)/100));
-			else
-				t1 = rand_fini(1, floor(tmp_size*(60-10*i/4)/100));
-		}
-		tmp_size -= t1;
-		taille.push_back(t1);
-	}
-
-	taille.push_back(tmp_size);
-
-	for(uint id_size = 0; id_size < taille.size(); id_size ++){
-		Entiers *part = new Entiers();
-		uint cpt_taille = 0;
-		while(cpt_taille < taille.at(id_size)){
-			part->push_back(random_order.at(cpt));
-			cpt_taille++;
-			cpt++;
-		}
-		Partition.push_back(part);
-	}
-
-	for(uint i = 0 ; i < Partition.size() ; i++){
-		sort(Partition.at(i)->begin(),Partition.at(i)->end());
-	}
-
-	return Partition;
-}
-
-void Coarsening_Phase(Base_Graph &baseg, ListEntiersEntiers &liste_corr,
-					  uint niveau, int nbr_vertex,
-					  std::string parameter){
-	uint cpt = 0;
-	bool stop = false;
-
-    while(!stop){
-    	if(parameter == "HEM")
-			stop = contraction_HEM(baseg.at(cpt), baseg,
-									liste_corr, niveau, nbr_vertex);
-		else if(parameter == "HEM_degree")
-			stop = contraction_HEM_degree(baseg.at(cpt), baseg,
-									liste_corr, niveau, nbr_vertex);
-    	else
-    		stop = contraction_Random_Maching(baseg.at(cpt), baseg,
-									liste_corr, niveau, nbr_vertex);
-        cpt++;
-    }
-    // std::cout<<std::endl;
-
-}
-
-EntiersEntiers Partitioning_Phase(const Base_Graph &baseg,
-					const std::vector<uint> &numeric_parameters,
-					const std::vector<std::string> &parameters,
-					int distance){
-
-    EntiersEntiers Partition;
-    if(parameters.at(1) == "gggp" || parameters.at(1) == "ggp"){
-		Entiers *part = new Entiers();
-		for(uint i = 0; i<num_vertices(*baseg.at(baseg.size() - 1)); i++)
-			part->push_back(i);
-		Partition.push_back(part);
-		bissectionRec(baseg.at(baseg.size()-1), Partition,
-					  numeric_parameters.at(1), parameters.at(3),
-					  numeric_parameters.at(2), parameters.at(1),
-					  distance);
-    }
-    else if(parameters.at(1) == "rand")
-    	Partition = Random_partitioning(baseg.at(baseg.size()-1),
-										numeric_parameters.at(1));
-	else
-		Partition = Random_equal_weight_partitioning(baseg.at(baseg.size()-1),
-										numeric_parameters.at(1));
-
-	return Partition;
-
-}
-
-void Uncoarsening_Phase(const Base_Graph &baseg,
-						EntiersEntiers &Partition,
-						const std::vector<std::string> &parameters,
-						ListEntiersEntiers &liste_corr,
-						double poids_moy, bool rec){
-
-    ListEntiersEntiers::iterator lit(liste_corr.end());
-    bool proj;
-    uint taille_list = liste_corr.size();
-    if(liste_corr.size()==0){
-    	taille_list = 1;
-    	proj = true;
-    }
-    else{
-    	lit--;
-    	proj = false;
-    }
-
-	std::vector<const char* > nom;
-	std::vector<const char* > nom_a;
-	if(rec){
-		const char * tmp_nom1 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_1.txt";
-		nom.push_back(tmp_nom1);
-		const char * tmp_nom_a1 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_1.txt";
-		nom_a.push_back(tmp_nom_a1);
-		const char * tmp_nom2 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_2.txt";
-		nom.push_back(tmp_nom2);
-		const char * tmp_nom_a2 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_2.txt";
-		nom_a.push_back(tmp_nom_a2);
-		const char * tmp_nom3 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_3.txt";
-		nom.push_back(tmp_nom3);
-		const char * tmp_nom_a3 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_3.txt";
-		nom_a.push_back(tmp_nom_a3);
-		const char * tmp_nom4 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_4.txt";
-		nom.push_back(tmp_nom4);
-		const char * tmp_nom_a4 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_4.txt";
-		nom_a.push_back(tmp_nom_a4);
-		const char * tmp_nom5 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_5.txt";
-		nom.push_back(tmp_nom5);
-		const char * tmp_nom_a5 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_5.txt";
-		nom_a.push_back(tmp_nom_a5);
-		const char * tmp_nom6 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_6.txt";
-		nom.push_back(tmp_nom6);
-		const char * tmp_nom_a6 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_6.txt";
-		nom_a.push_back(tmp_nom_a6);
-		const char * tmp_nom7 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_7.txt";
-		nom.push_back(tmp_nom7);
-		const char * tmp_nom_a7 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_7.txt";
-		nom_a.push_back(tmp_nom_a7);
-		const char * tmp_nom8= "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_8.txt";
-		nom.push_back(tmp_nom8);
-		const char * tmp_nom_a8 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_8.txt";
-		nom_a.push_back(tmp_nom_a8);
-		const char * tmp_nom9 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_9.txt";
-		nom.push_back(tmp_nom9);
-		const char * tmp_nom_a9 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_9.txt";
-		nom_a.push_back(tmp_nom_a9);
-		const char * tmp_nom10 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_10.txt";
-		nom.push_back(tmp_nom10);
-		const char * tmp_nom_a10 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_10.txt";
-		nom_a.push_back(tmp_nom_a10);
-		const char * tmp_nom11 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_11.txt";
-		nom.push_back(tmp_nom11);
-		const char * tmp_nom_a11 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_11.txt";
-		nom_a.push_back(tmp_nom_a11);
-		const char * tmp_nom12 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_12.txt";
-		nom.push_back(tmp_nom12);
-		const char * tmp_nom_a12 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_12.txt";
-		nom_a.push_back(tmp_nom_a12);
-		const char * tmp_nom13 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_13.txt";
-		nom.push_back(tmp_nom13);
-		const char * tmp_nom_a13 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_13.txt";
-		nom_a.push_back(tmp_nom_a13);
-		const char * tmp_nom14 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_14.txt";
-		nom.push_back(tmp_nom14);
-		const char * tmp_nom_a14 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_14.txt";
-		nom_a.push_back(tmp_nom_a14);
-		const char * tmp_nom15 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_15.txt";
-		nom.push_back(tmp_nom15);
-		const char * tmp_nom_a15 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_15.txt";
-		nom_a.push_back(tmp_nom_a15);
-		const char * tmp_nom16 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_16.txt";
-		nom.push_back(tmp_nom16);
-		const char * tmp_nom_a16 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_16.txt";
-		nom_a.push_back(tmp_nom_a16);
-	}
-
-    for(uint y =0 ; y < taille_list ; y++){
-    	if(!proj){
-    		projection(Partition,lit);
-    		if(rec)
-				Plot_UnorientedGraph_All(baseg.at(baseg.size()-2-y),
-										 Partition,nom.at(y), true);
-
-    		double cut = Cut_cluster(Partition,
-										*baseg.at(baseg.size()-2-y),
-										parameters.at(3));
-    		if(parameters.at(2) == "charge")
-    			Affinage_equilibrage_charge(baseg.at(baseg.size()-2-y),
-										Partition);
-    		else if(parameters.at(2) == "locale"){
-    			Affinage_recherche_locale(baseg.at(baseg.size()-2-y),
-										Partition, cut, parameters.at(3));}
-    		else
-    			Affinache_gain_diff(baseg.at(baseg.size()-2-y),
-										Partition, cut,
-										parameters.at(3), poids_moy);
-
-			if(rec)
-				Plot_UnorientedGraph_All(baseg.at(baseg.size()-2-y),
-										Partition, nom_a.at(y), true);
-
-    		lit--;
-    	}
-
-    }
-}
-
-/* std::vector<std::string> parameters :
- * 0 -> contraction    : nom de la méthode de contraction
- * 1 -> type_methode   : nom de la méthode de partitionnement
- * 2 -> choix_affinage : nom de la méthode d'affinage
- * 3 -> type_cut       : nom de la fonction objectif étudiée
- *
- * std::vector<uint> numeric_parameters :
- * 0 -> niveau_contraction : niveau de contraction à atteindre
- * 1 -> nbr_parties        : nombre de parties de la partition
- * 2 -> nbr_tirage         : nombre de tirage de sommet de depart
- * 3 -> distance           : distance minimum de selection de sommet
- * 							 de depart par default -1
- */
-
-OrientedGraphs Multiniveau(OrientedGraph *go,
-                           const std::vector<uint> &numeric_parameters,
-                           const std::vector<std::string> &parameters,
-                           Edges& /* edge_partie */,
-                           OutputEdgeList& outputedgelist,
-                           InputEdgeList& inputedgelist,
-                           Connections& connections,
-                           bool rec, int distance)
-{
-    boost::timer t;
-    double t1, t2, t3, t4;
-    UnorientedGraph *g = new UnorientedGraph();
-	make_unoriented_graph(*go, *g);
-	UnorientedGraph *copie = new UnorientedGraph();
-	boost::copy_graph(*g,*copie);
-	//Plot_UnorientedGraph(copie,"lifegame.txt");
-    Base_Graph baseg;
-    //baseg.push_back(g);
-    ListEntiersEntiers liste_corr;
-    OrientedGraphs Graphes;
-    int val_cpt = num_vertices(*g);
-    bool time = true;
-    
-
-    /*Eigen::MatrixXd Madj = adjacence_matrix(g);
-	std::cout << Madj << std::endl << std::endl;*/
-
-    if(numeric_parameters.at(0) != val_cpt && parameters.at(1) != "rand" && parameters.at(1) != "rande"){
-		
-		simple_graph(copie);
-		baseg.push_back(copie);
-		//Plot_UnorientedGraph(copie,"lifegame2.txt");
-		Coarsening_Phase(baseg, liste_corr, numeric_parameters.at(0), val_cpt, parameters.at(0));
-
-	    if(rec){
-			std::ofstream GRAPHp ("../../sortie_graphe/Tests/Graphes/Bissection/poids_graphe.txt", std::ios::out);
-			GRAPHp<<"Poids du graphe contracté : "<<std::endl;
-			tie(vertexIt, vertexEnd) = vertices(*baseg.at(baseg.size()-1));
-			for (; vertexIt != vertexEnd; ++vertexIt) {
-				GRAPHp<<(*baseg.at(baseg.size()-1))[*vertexIt]._index<<" --> "<<(*baseg.at(baseg.size()-1))[*vertexIt]._weight<<std::endl;;
-			}
-			GRAPHp<<"}";
-			GRAPHp.close();
-		}
-
-		if(time){
-			t2 = t.elapsed();
-			// std::cout << "C : " << t2 << " ; ";
-		}
-
-	    if(rec)
-			Plot_UnorientedGraph(baseg.at(baseg.size()-1),"../../sortie_graphe/Tests/Graphes/Multiniveau/txt/contraction_final.txt");
-
-		UnorientedGraph copy_graph;
-		boost::copy_graph(*baseg.at(baseg.size()-1),copy_graph);
-
-		EntiersEntiers Partition = Partitioning_Phase(baseg,
-							numeric_parameters, parameters, distance);
-
-	    if(time){
-			t3 = t.elapsed();
-			// std::cout << "P : " << (t3 - t2) << " ; ";
-	    }
-
-	    if(rec)
-			Plot_UnorientedGraph_All(&copy_graph,Partition,"../../sortie_graphe/Tests/Graphes/Multiniveau/txt/contraction_final_partition.txt", true);
-
-		double poids_moy = 0.;
-		for(uint i =0; i < Partition.size(); i++)
-			poids_moy += Cluster_Weight(copy_graph,*Partition.at(i));
-		poids_moy/=Partition.size();
-		poids_moy = -1; /*poids faible*/
-
-		Uncoarsening_Phase(baseg, Partition, parameters,
-								  liste_corr, poids_moy, rec);
-
-		if(time){
-			t4 = t.elapsed();
-			// std::cout << "A : " << (t4 - t3) << " ; "<<std::endl;
-	    }
-
-	    for(uint si = 0; si < Partition.size(); si++){
-			// std::cout<<Partition.at(si)->size()<<std::endl;
-		}
-		// std::cout<<std::endl;
-
-	    double ratio_cut = Cut_cluster(Partition, *g, parameters.at(3));
-	    // std::cout<<"Ratio : "<<ratio_cut<<std::endl;
-
-		Graphes = Graph_Partition(Partition, go, g, outputedgelist,
-	                              inputedgelist, connections);
-	    if(rec)
-			Plot_OrientedGraph_All(go,Partition,"../../sortie_graphe/Tests/Graphes/Multiniveau/txt/résultat_partitionnement.txt", true);
-		
-		delete g;
-		for(uint it = 0 ; it < Partition.size(); it++ )
-		{
-			delete Partition.at(it);
-		}
-	}else{
-		UnorientedGraph *copie_g = new UnorientedGraph();
-		boost::copy_graph(*g,*copie_g);
-		baseg.push_back(g);
-
-		EntiersEntiers Partition = Partitioning_Phase(baseg,
-								   numeric_parameters, parameters,
-								   distance);
-
-		if(time){
-		    t1 = t.elapsed();
-			// std::cout << "P : " << t1 << " ; "<<std::endl;
-	    }
-
-	    for(uint si = 0; si < Partition.size(); si++){
-			// std::cout<<Partition.at(si)->size()<<std::endl;
-		}
-		// std::cout<<std::endl;
-
-	    double ratio_cut = Cut_cluster(Partition, *copie_g, parameters.at(3));
-	    // std::cout<<"Ratio : "<<ratio_cut<<std::endl;
-
-		Graphes = Graph_Partition(Partition, go, copie_g,
-								  outputedgelist, inputedgelist,
-								  connections);
-
-        if(rec)
-			Plot_OrientedGraph_All(go,Partition,"../../sortie_graphe/Tests/Graphes/Multiniveau/txt/résultat_partitionnement.txt", true);
-
-		delete copie_g;
-		for(uint it = 0 ; it < Partition.size(); it++ )
-		{
-			delete Partition.at(it);
-		}
-	}
-
-    for(ListEntiersEntiers::iterator it = liste_corr.begin(); it != liste_corr.end(); it++)
-    {
-        for(EntiersEntiers::iterator it1 = (*it)->begin(); it1 != (*it)->end(); it1++)
-        {
-            delete *it1;
-            *it1 = NULL;
-        }
-        delete *it;
-        *it = NULL;
-    }
-
-    for(Base_Graph::iterator it = baseg.begin(); it != baseg.end(); it++)
-    {
-        delete *it;
-        *it = NULL;
-    }
-
-    return Graphes;
-}
-
-void Optimisation_method_neighbour(UnorientedGraph *g,
-			EntiersEntiers &Partition, int index_partition,
-			int nbr_tirage, const std::string &name_cut,
-			const std::string &name_strat){
-
-	/*Initialisation des parametres*/
-	Entiers *part2_cons = new Entiers();
-	Entiers *part_cour_cons = new Entiers();
-	double cut = 1000000000.;
-
-	Entiers Random_list_vertices =  Random_Sort_Vector(Partition.at(index_partition)->size());
-
-	if(Partition.at(index_partition)->size()< nbr_tirage)
-		nbr_tirage = Partition.at(index_partition)->size();
-
-	/*Boucle de conservation de la meilleure bissection*/
-	for(int k = 0; k<nbr_tirage; k++){
-		Entiers *part2 = new Entiers();
-		Entiers *tmp_part = new Entiers();
-		double new_cut;
-
-		/*Recopie de la partie faisant l'objet de la bissection */
-		for(uint t=0; t<Partition.at(index_partition)->size();t++)
-			tmp_part->push_back(Partition.at(index_partition)->at(t));
-
-		if(name_strat == "gggp")
-			gggp_pond(g, tmp_part, part2, Partition,
-					  Random_list_vertices.at(k), index_partition,
-					  name_cut , -1);
-		else if(name_strat == "ggp")
-			ggp(g, tmp_part, part2, Partition,
-					  Random_list_vertices.at(k), index_partition ,-1);
-		else
-			std::cout<<"Nom de stratégie de partitionnement non valide ! "<<std::endl;
-
-		new_cut = Best_Cut_cluster(Partition, tmp_part,
-					  part2, index_partition, *g, name_cut);
-
-		/*conservation de l'information en cas d'amélioration
-		 * de la contrainte*/
-		if(new_cut<cut){
-			cut = new_cut;
-			delete part2_cons;
-			delete part_cour_cons;
-			part2_cons = part2;
-			part_cour_cons = tmp_part;
-		}
-		else{
-			delete tmp_part;
-			delete part2;
-		}
-	}
-
-	for (uint i=0; i<part_cour_cons->size();i++)
-    {
-        for (uint j=0; j<part2_cons->size();j++)
-        {
-            remove_edge(part_cour_cons->at(i),part2_cons->at(j),*g);
-        }
-    }
-
-	/*Modification des informations*/
-	delete Partition.at(index_partition);
-	Partition.at(index_partition)=part_cour_cons;
-	Partition.push_back(part2_cons);
-}
-
-void Optimisation_method_neighbour_distance(UnorientedGraph *g,
-			EntiersEntiers &Partition, int index_partition,
-			int nbr_tirage, int distance, const std::string &name_cut,
-			const std::string &name_strat){
-
-	/*Initialisation des parametres*/
-	Entiers *part2_cons = new Entiers();
-	Entiers *part_cour_cons = new Entiers();
-	double cut=1000000000.;
-	int val;
-
-	std::list<int> vertex_list;
-	for(uint verx =0; verx<Partition.at(index_partition)->size(); verx++){
-		vertex_list.push_back(Partition.at(index_partition)->at(verx));
-	}
-
-	if(Partition.at(index_partition)->size()< nbr_tirage)
-		nbr_tirage = Partition.at(index_partition)->size();
-
-	/*Boucle de conservation de la meilleure bissection*/
-	for(int k = 0; k<nbr_tirage; k++){
-		std::list<int>::iterator Iter;
-		if(vertex_list.size()!=0){
-			Iter = vertex_list.begin();
-			for(int i = 0; i<rand_fini(0,vertex_list.size()); i++)
-				Iter++;
-			val = *Iter;
-			tirage_distance(g, *Iter, vertex_list, distance);
-		}
-		else{
-			break;
-		}
-
-		Entiers *part2 = new Entiers();
-		Entiers *tmp_part = new Entiers();
-		double new_cut;
-
-		/*Recopie de la partie faisant l'objet de la bissection*/
-		for(uint t=0; t<Partition.at(index_partition)->size();t++)
-			tmp_part->push_back(Partition.at(index_partition)->at(t));
-
-		if(name_strat == "gggp")
-			gggp_pond(g, tmp_part, part2, Partition, val,
-					  index_partition, name_cut, distance);
-		else if(name_strat == "ggp")
-			ggp(g, tmp_part, part2, Partition, val,
-					  index_partition, distance);
-		else
-			std::cout<<"Nom de stratégie de partitionnement non valide ! "<<std::endl;
-
-		new_cut = Best_Cut_cluster(Partition, tmp_part, part2,
-					  index_partition, *g,name_cut);
-
-		if(new_cut<cut){
-			cut = new_cut;
-			delete part2_cons;
-			delete part_cour_cons;
-			part2_cons = part2;
-			part_cour_cons = tmp_part;
-		}
-		else{
-			delete tmp_part;
-			delete part2;
-		}
-	}
-
-	for (uint i=0; i<part_cour_cons->size();i++)
-    {
-        for (uint j=0; j<part2_cons->size();j++)
-        {
-			remove_edge(part_cour_cons->at(i), part2_cons->at(j), *g);
-        }
-    }
-
-	/*Modification des informations*/
-	delete Partition.at(index_partition);
-	Partition.at(index_partition)=part_cour_cons;
-	Partition.push_back(part2_cons);
-}
-
-void Optimisation_method_neighbour_degree(UnorientedGraph *g,
-			EntiersEntiers &Partition, int index_partition,
-			const std::string &name_cut,
-			const std::string &name_strat){
-
-	std::vector<double> vertex_degree;
-	Entiers *part2 = new Entiers();
-
-	for(uint i =0; i<Partition.at(index_partition)->size(); i++)
-		vertex_degree.push_back(Degree(*g,
-								Partition.at(index_partition)->at(i)));
-
-
-	uint best_cpt = 0;
-	double  best_degree = vertex_degree.at(0);
-
-	for(uint i =1; i<vertex_degree.size(); i++){
-		if(vertex_degree.at(i)>best_degree){
-			best_degree = vertex_degree.at(i);
-			best_cpt = i;
-		}
-	}
-
-	if(name_strat == "gggp")
-		gggp_pond(g, Partition.at(index_partition), part2,
-				  Partition, best_cpt, index_partition,
-				  name_cut, -1);
-	else if(name_strat == "ggp")
-		ggp(g ,Partition.at(index_partition), part2, Partition,
-				  best_cpt, index_partition, -1);
-	else
-		std::cout<<"Nom de stratégie de partitionnement non valide ! "<<std::endl;
-
-	for (uint i=0; i<Partition.at(index_partition)->size();i++){
-        for (uint j=0; j<part2->size();j++){
-			remove_edge(Partition.at(index_partition)->at(i),
-						part2->at(j), *g);
-        }
-    }
-
-	Partition.push_back(part2);
-}
-
-void Optimisation_method_neighbour_minweight(UnorientedGraph *g,
-					EntiersEntiers &Partition, int index_partition,
-					const std::string &name_cut,
-					const std::string &name_strat){
-
-	std::vector<double> vertex_weight;
-	Entiers *part2 = new Entiers();
-
-	for(uint i =0; i<Partition.at(index_partition)->size(); i++){
-		vertex_weight.push_back((*g)[Partition.at(index_partition)->at(i)]._weight);
-	}
-
-	uint best_cpt = 0;
-	double  best_weight = vertex_weight.at(0);
-
-	for(uint i =1; i<vertex_weight.size(); i++){
-		if(vertex_weight.at(i)>best_weight){
-			best_weight = vertex_weight.at(i);
-			best_cpt = i;
-		}
-	}
-
-	if(name_cut == "ratio"){
-		int tmp_best_cpt;
-		tmp_best_cpt = Partition.at(index_partition)->at(best_cpt);
-		best_cpt = tmp_best_cpt;
-	}
-
-	if(name_strat == "gggp"){
-		gggp_pond(g, Partition.at(index_partition), part2,
-					 Partition, best_cpt, index_partition,
-					 name_cut, -1);
-	} else if(name_strat == "ggp"){
-		ggp(g, Partition.at(index_partition), part2,
-					 Partition, best_cpt, index_partition, -1);
-	} else {
-		std::cout<<"Nom de stratégie de partitionnement non valide ! "<<std::endl;
-	}
-
-	for (uint i=0; i<Partition.at(index_partition)->size();i++)
-    {
-        for (uint j=0; j<part2->size();j++)
-        {
-			remove_edge(Partition.at(index_partition)->at(i),
-					 part2->at(j), *g);
-        }
-    }
-
-	Partition.push_back(part2);
-
-}
-
-void tirage_distance(UnorientedGraph *g, int tirage,
-						std::list<int> &vertex_list, int distance){
-	std::vector<std::list<int> > vertex_delete;
-	std::list<int> liste1;
-	std::list<int> vd;
-
-	liste1.push_back(tirage);
-	vertex_delete.push_back(liste1);
-
-	for(int i=0; i<distance; i++){
-		std::list<int> liste_tmp;
-		std::list<int>::iterator Ite_tmp;
-		for(Ite_tmp = vertex_delete.at(i).begin();
-								Ite_tmp != vertex_delete.at(i).end();
-								Ite_tmp ++){
-			tie(neighbourIt, neighbourEnd) =
-								adjacent_vertices(*Ite_tmp,*g);
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-				liste_tmp.push_back(*neighbourIt);
-			}
-		}
-		liste_tmp.sort();
-		liste_tmp.unique();
-		vertex_delete.push_back(liste_tmp);
-	}
-
-	for(int index = 0; index < vertex_delete.size(); index ++){
-		vd.merge(vertex_delete.at(index));
-	}
-	vd.unique();
-
-	std::list<int>::iterator Ite;
-	for(Ite = vd.begin(); Ite != vd.end(); Ite ++){
-		vertex_list.remove(*Ite);
-	}
-}
-
-} } } // namespace paradevs tests boost_graph

+ 1217 - 0
src/tests/boost_graph/partitioning/gggp.hpp

@@ -102,6 +102,1223 @@ void Optimisation_method_neighbour_minweight(UnorientedGraph *g,
 void tirage_distance(UnorientedGraph *g, int tirage,
                      std::list<int> &vertex_list, int distance);
 
+void ggp(UnorientedGraph *g, Entiers *sommetsSource,
+               Entiers *sommetsDestination, EntiersEntiers &Partition, int rand, int &index_partition, int distance)
+{
+    Entiers sommets_adj;
+    if(sommetsSource->size()==1){
+        Entiers tailles;
+        for(uint i=0;i<Partition.size();i++){
+            tailles.push_back(Partition.at(i)->size());
+        }
+        uint tmp=*max_element(tailles.begin(),tailles.end());
+        for(uint i=0; i<Partition.size();i++){
+            if(Partition.at(i)->size() == tmp)
+            {
+				sommetsSource->clear();
+				for(uint id = 0; id < Partition.at(i)->size();id++){
+					sommetsSource->push_back(Partition.at(i)->at(id));
+				}
+				index_partition = i;
+				if(distance != -1){
+					ggp(g, sommetsSource, sommetsDestination, Partition,
+						Partition.at(i)->at(rand_fini(0,Partition.at(i)->size())),
+						index_partition, distance);
+				}else{
+					ggp(g, sommetsSource, sommetsDestination, Partition,
+						rand_fini(0,Partition.at(i)->size()),
+						index_partition, distance);
+				}
+                return;
+            }
+        }
+    }
+
+    double poids_max=0;
+    for(uint i=0;i<sommetsSource->size();i++){
+        poids_max+=(*g)[sommetsSource->at(i)]._weight;
+    }
+    poids_max/=2.;
+
+	double poids;
+    if(distance == -1){
+		poids=(*g)[sommetsSource->at(rand)]._weight;
+		sommetsDestination->push_back(sommetsSource->at(rand));
+		sommetsSource->erase(sommetsSource->begin() + rand);
+
+	}else{
+		poids=(*g)[rand]._weight;
+		sommetsDestination->push_back(rand);
+		suprim_val(*sommetsSource,rand);
+	}
+
+    uint cpt = 0;
+    while(poids<poids_max && sommetsSource->size()>1)
+    {
+        if(cpt<sommetsDestination->size()){
+            adjacence_ggp(sommetsDestination->at(cpt),sommets_adj,g);
+		} else{
+            int val=rand_fini(0,sommetsSource->size()-1);
+            sommetsDestination->push_back(sommetsSource->at(val));
+            sommetsSource->erase(sommetsSource->begin() + val);
+            adjacence_ggp(sommetsDestination->at(cpt),sommets_adj,g);
+        }
+        if(sommets_adj.size() == 0)
+        {
+            sort(sommetsDestination->begin(), sommetsDestination->end());
+            return;
+        }
+        else{
+            for(uint i =0; i<sommets_adj.size(); i++){
+                if(In_tab(*sommetsDestination,sommets_adj.at(i)) != 1 && sommetsSource->size()!=1){
+                    sommetsDestination->push_back(sommets_adj.at(i));
+                    poids+=(*g)[sommets_adj.at(i)]._weight;
+                    suprim_val(*sommetsSource, sommets_adj[i]);
+                }
+                else if(poids>=poids_max || sommetsSource->size() == 1){
+					sort(sommetsDestination->begin(), sommetsDestination->end());
+					return;
+				}
+            }
+
+            /*std::cout<<"Sommets_source :"<<std::endl;
+            for(uint i =0; i<sommetsSource->size();i++){
+                std::cout<<sommetsSource->at(i)<<",";
+            }
+            std::cout<<std::endl;
+            std::cout<<"Sommets_destination :"<<std::endl;
+            for(uint i =0; i<sommetsDestination->size();i++){
+                std::cout<<sommetsDestination->at(i)<<",";
+            }
+            std::cout<<std::endl;*/
+        }
+        sommets_adj.clear();
+        cpt++;
+
+    }
+
+    sort(sommetsDestination->begin(), sommetsDestination->end());
+}
+
+void Transfert_vertex_bissection(UnorientedGraph *g, Entiers *sommetsSource, Entiers *sommetsDestination, Entiers &sommets_adj, const std::string &name, double &poids, double &cut){
+	std::vector<double> sommets_cut;
+	sort(sommets_adj.begin(), sommets_adj.end());
+	for(uint i=0;i<sommets_adj.size();i++)
+	{
+		double tmp_cut = cut;
+		if(name == "cut"){
+			sommets_cut.push_back(modif_Cout_coupe(*sommetsDestination,sommets_adj.at(i),tmp_cut,g));
+		}else if(name == "ratio"){
+			//std::cout<<"adj : "<<(*g)[sommets_adj.at(i)]._index<<" cut = "<<Modif_ratio_cut(g, sommetsSource, sommetsDestination, sommets_adj.at(i), tmp_cut)<<std::endl;
+			sommets_cut.push_back(Modif_ratio_cut(g, sommetsSource, sommetsDestination, sommets_adj.at(i), tmp_cut));
+		}
+	}
+
+	cut = *min_element(sommets_cut.begin(),sommets_cut.end());
+	//std::cout<<"*** Passage 3 cut ***** : "<<cut<<std::endl;
+	//std::cout<<"Meilleur voisin : "<<(*g)[sommets_adj.at(recherche_val_double(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end())))]._index<<std::endl;
+	sommetsDestination->push_back(sommets_adj[recherche_val_double(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
+	//std::cout<<"*** Passage 3 cuta ***"<<std::endl;
+	poids+=(*g)[sommets_adj[recherche_val_double(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]]._weight;
+	//std::cout<<"*** Passage 3 cutb ***"<<std::endl;
+	suprim_val(*sommetsSource, sommets_adj[recherche_val_double(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
+	suprim_val(sommets_adj, sommets_adj[recherche_val_double(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
+
+	//std::cout<<"*** Passage 3 fin ***"<<std::endl;
+
+}
+
+void Tirage_transfert_vertex_bissection(UnorientedGraph *g, Entiers *sommetsSource, Entiers *sommetsDestination, const std::string &name, double &poids, double &cut){
+	double diff = -100.;
+	uint tmp_tir;
+	while(diff != 0){
+		tmp_tir = sommetsSource->at(rand_fini(0,sommetsSource->size()));
+		diff = Diff_cut_ratio_bissection(g, sommetsSource, tmp_tir, name);
+	}
+	poids += (*g)[tmp_tir]._weight;
+	if(name == "cut"){
+		cut = modif_Cout_coupe(*sommetsDestination,tmp_tir,cut,g);
+	}else{
+		cut = Modif_ratio_cut(g, sommetsSource, sommetsDestination, tmp_tir, cut);
+	}
+	sommetsDestination->push_back(tmp_tir);
+	suprim_val(*sommetsSource,tmp_tir);
+}
+
+bool Best_transfert_vertex_bissection(UnorientedGraph *g, Entiers *sommetsSource, Entiers *sommetsDestination, Entiers &sommets_adj,
+									  const std::string &name, double &poids, double poids_max, double PC, int stop, int &cpt, double &cut){
+    Liste_Voisin(*sommetsDestination,sommets_adj,*g);
+    //sort(sommets_adj.begin(), sommets_adj.end());
+	if((sommets_adj.size() == 0) & (cpt<stop) & (sommetsSource->size()>1))
+	{
+		cpt++;
+		//std::cout<<"*** Passage 1 ***"<<std::endl;
+		if(poids < (poids_max - poids_max*PC/100)){
+			//std::cout<<"*** Passage 1a ***"<<std::endl;
+			Tirage_transfert_vertex_bissection(g, sommetsSource, sommetsDestination, name, poids, cut);
+			if((poids < (poids_max - poids_max*PC/100)) & (sommetsSource->size()>1)){
+				Best_transfert_vertex_bissection(g, sommetsSource, sommetsDestination, sommets_adj,
+												name, poids, poids_max, PC, stop, cpt, cut);
+			}else{
+				//std::cout<<"*** Passage 1ac ***"<<std::endl;
+				return true;
+			}
+		}else{
+			//std::cout<<"*** Passage 1b ***"<<std::endl;
+			return true;
+		}
+
+	}
+	else if ((sommets_adj.size() == 0) & (cpt>=stop)){
+		//std::cout<<"*** Passage 2 ***"<<std::endl;
+		return true;
+	}else if (sommetsSource->size()==1){
+		//std::cout<<"*** Passage 4 ***"<<std::endl;
+		return true;
+	}else{
+		//std::cout<<"*** Passage 3 *** : "<<cut<<std::endl;
+		Transfert_vertex_bissection(g, sommetsSource, sommetsDestination, sommets_adj, name, poids, cut);
+		return false;
+	}
+}
+
+void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource, Entiers *sommetsDestination,
+				EntiersEntiers &Partition, int rand, int &index_partition, const std::string &name, int distance)
+{
+    Entiers sommets_adj;
+    double poids_max = 0;
+    double poids, cut;
+
+    if(sommetsSource->size()==1){
+        Entiers tailles;
+        for(uint i=0;i<Partition.size();i++){
+            tailles.push_back(Partition.at(i)->size());
+        }
+        uint tmp=*max_element(tailles.begin(),tailles.end());
+        for(uint i=0; i<Partition.size();i++){
+            if(Partition.at(i)->size()==tmp)
+            {
+				sommetsSource->clear();
+				for(uint id = 0; id < Partition.at(i)->size();id++){
+					sommetsSource->push_back(Partition.at(i)->at(id));
+				}
+				index_partition = i;
+				if(distance != -1)
+					gggp_pond(g,sommetsSource,sommetsDestination,Partition,
+						Partition.at(i)->at(rand_fini(0,Partition.at(i)->size())),
+						index_partition, name, distance);
+				else
+					gggp_pond(g, sommetsSource, sommetsDestination,
+						Partition, rand_fini(0,Partition.at(i)->size()),
+						index_partition, name ,distance);
+                return;
+            }
+        }
+    }
+
+    for(uint i=0;i<sommetsSource->size();i++){
+        poids_max+=(*g)[sommetsSource->at(i)]._weight;
+    }
+    poids_max/=2.;
+
+    if(distance == -1){
+		poids=(*g)[sommetsSource->at(rand)]._weight;
+		if(name == "cut"){
+			cut = Degree(*g,sommetsSource->at(rand));
+		}else if(name == "ratio"){
+			cut = Degree(*g,sommetsSource->at(rand));
+			double tmp_cut = cut/2./(*g)[sommetsSource->at(rand)]._weight
+				   + cut/2./(Cluster_Weight(*g,*sommetsSource)-(*g)[sommetsSource->at(rand)]._weight);
+			cut = tmp_cut;
+		}
+		sommetsDestination->push_back(sommetsSource->at(rand));
+		sommetsSource->erase(sommetsSource->begin() + rand);
+	}else{
+		poids=(*g)[rand]._weight;
+		cut = Degree(*g,rand);
+		if(name == "ratio"){
+			double tmp_cut = cut/2./(*g)[rand]._weight + cut/2./(Cluster_Weight(*g,*sommetsSource)-(*g)[rand]._weight);
+			cut = tmp_cut;
+		}
+		sommetsDestination->push_back(rand);
+		suprim_val(*sommetsSource,rand);
+	}
+
+    while(poids<poids_max && sommetsSource->size()>1)
+    {
+		int cpt = 0;
+        bool next = Best_transfert_vertex_bissection(g, sommetsSource, sommetsDestination, sommets_adj,
+													name, poids, poids_max, 20, 2, cpt, cut);
+		if(next == true){
+			sort(sommetsDestination->begin(), sommetsDestination->end());
+			return;
+		}
+    }
+    sort(sommetsDestination->begin(), sommetsDestination->end());
+}
+
+/*Liste_Voisin(*sommetsDestination,sommets_adj,*g);
+if(sommets_adj.size()==0)
+{
+	std::cout<<"*** Passage ***"<<std::endl;
+	if(poids < (poids_max - poids_max*40/100)){
+		Tirage_transfert_vertex_bissection(g, sommetsSource, sommetsDestination, name, poids);
+
+		Liste_Voisin(*sommetsDestination,sommets_adj,*g);
+		if(sommets_adj.size() != 0){
+			Transfert_vertex_bissection(g, sommetsSource, sommetsDestination, sommets_adj, name, poids);
+		}else{
+			sort(sommetsDestination->begin(), sommetsDestination->end());
+			return;
+		}
+	}else{
+		sort(sommetsDestination->begin(), sommetsDestination->end());
+		return;
+	}
+
+}
+else{
+	Transfert_vertex_bissection(g, sommetsSource, sommetsDestination, sommets_adj, name, poids);
+}*/
+
+
+void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
+             const std::string &nom_cut, int nbr_tirage,
+             const std::string &nom_strat, bool rec, int distance)
+{
+
+	UnorientedGraph copy_graph;
+UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+	boost::copy_graph(*g,copy_graph);
+	int cpt = 0;
+
+	for(int i = 0; i<floor(log(nbr_parties)/log(2)); i++){
+		for(int j = 0; j< pow(2,i);j++) {
+			if(distance == -1){
+				if(nbr_tirage != 0)
+					Optimisation_method_neighbour(g,part,j,nbr_tirage, nom_cut, nom_strat);
+				else
+					Optimisation_method_neighbour_minweight(g,part,j, nom_cut, nom_strat);
+			}else
+				Optimisation_method_neighbour_distance(g,part,j,nbr_tirage, distance, nom_cut, nom_strat);
+
+			if(rec){
+				std::vector<std::string> color;
+				color.push_back("[color=blue2, fontcolor=blue2];");
+				color.push_back("[color=red, fontcolor=red];");
+				color.push_back("[color=green, fontcolor=green];");
+				color.push_back("[color=turquoise, fontcolor=turquoise];");
+				color.push_back("[color=saddlebrown, fontcolor=saddlebrown];");
+				color.push_back("[color=indigo, fontcolor=indigo];");
+				color.push_back("[color=yellow, fontcolor=yellow2];");
+				color.push_back("[color=orange, fontcolor=orange];");
+				color.push_back("[color=olivedrab, fontcolor=olivedrab];");
+				color.push_back("[color=gold, fontcolor=gold];");
+				color.push_back("[color=slateblue2, fontcolor=slateblue2];");
+				color.push_back("[color=dimgrey, fontcolor=dimgrey];");
+				color.push_back("[color=cyan, fontcolor=cyan];");
+				color.push_back("[color=purple1, fontcolor=purpule1];");
+				color.push_back("[color=crimson, fontcolor=crimson];");
+				color.push_back("[color=black, fontcolor=black];");
+
+	    		std::vector<char* > nom;
+				char * tmp_nom1 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_1.txt";
+				nom.push_back(tmp_nom1);
+				char * tmp_nom2 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_2.txt";
+				nom.push_back(tmp_nom2);
+				char * tmp_nom3 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_3.txt";
+				nom.push_back(tmp_nom3);
+				char * tmp_nom4 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_4.txt";
+				nom.push_back(tmp_nom4);
+				char * tmp_nom5 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_5.txt";
+				nom.push_back(tmp_nom5);
+				char * tmp_nom6 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_6.txt";
+				nom.push_back(tmp_nom6);
+				char * tmp_nom7 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_7.txt";
+				nom.push_back(tmp_nom7);
+				char * tmp_nom8 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_8.txt";
+				nom.push_back(tmp_nom8);
+				char * tmp_nom9 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_9.txt";
+				nom.push_back(tmp_nom9);
+				char * tmp_nom10 = "../../sortie_graphe/Tests/Graphes/Bissection/txt/bissection_10.txt";
+				nom.push_back(tmp_nom10);
+
+	    		std::ofstream GRAPH2 (nom.at(cpt), std::ios::out);
+				GRAPH2<<"graph G {"<<std::endl;
+				tie(vertexIt, vertexEnd) = vertices(copy_graph);
+				for (; vertexIt != vertexEnd; ++vertexIt) {
+					GRAPH2<<(copy_graph)[*vertexIt]._index<<" -- {";
+					tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
+	    			copy_graph);
+					for (; neighbourIt != neighbourEnd; ++neighbourIt){
+						if((copy_graph)[*neighbourIt]._index>(copy_graph)[*vertexIt]._index)
+							GRAPH2<<(copy_graph)[*neighbourIt]._index<<";";
+					}
+					GRAPH2<<"}"<<std::endl;
+				}
+
+				for(uint k=0; k<part.size(); k++){
+					for(uint t=0; t<part.at(k)->size(); t++)
+					{
+						GRAPH2<<(copy_graph)[part.at(k)->at(t)]._index<<color.at(k)<<std::endl;
+					}
+				}
+
+				GRAPH2<<"}";
+				GRAPH2.close();
+			}
+
+			cpt ++;
+		}
+    }
+}
+
+void bissectionRec(UnorientedGraph *g, EntiersEntiers &Partition,
+                   int nbr_parties, const std::string &nom_cut,
+                   int nbr_tirage, const std::string &nom_strat,
+                   int distance)
+{
+    if((nbr_parties&(nbr_parties-1)) == 0)
+        Iter_2l(Partition, nbr_parties, g, nom_cut, nbr_tirage,
+						   nom_strat, false, distance);
+    else{
+        int puissance_2=0;
+
+        Entiers tailles;
+
+        while(pow(2,puissance_2)<nbr_parties)
+            puissance_2++;
+
+        Iter_2l(Partition, pow(2,puissance_2-1), g,
+				nom_cut, nbr_tirage, nom_strat, false, distance);
+
+        for(unsigned int i = 0; i< Partition.size() -1 ; i++)
+        {
+            for(EntiersEntiers::iterator it1 = Partition.begin() + i ;
+				it1!=Partition.end(); it1++)
+            {
+                if((*it1)->size() > Partition.at(i)->size())
+                    Partition.at(i)->swap(**it1);
+            }
+        }
+
+        for(int j = 0; j<nbr_parties-pow(2,puissance_2-1);j++)
+        {
+			if(distance == -1){
+				if(nbr_tirage != 0){
+					Optimisation_method_neighbour(g, Partition, j,
+												  nbr_tirage, nom_cut,
+												  nom_strat);
+				}else{
+					Optimisation_method_neighbour_degree(g, Partition, j,
+												  nom_cut, nom_strat);
+				}
+			}else{
+				Optimisation_method_neighbour_distance(g, Partition, j,
+												  nbr_tirage, distance,
+												  nom_cut, nom_strat);
+			}
+        }
+    }
+}
+
+/**
+ * Fonction réalisant un partitionnement pseudo aléatoire suivant un voisinage.
+ * @param *g : adresse d'un graphe de type boost graphe undirected
+ * @param Partition : vecteur contenant des vecteurs d'entiers [tableau contenant les parties de la partition]
+ * @param nbr_partie : entier correspondant au nombre de parties voulues pour la partition
+ * @return
+ */
+
+void Pseudo_random_partitioning(UnorientedGraph *g, EntiersEntiers &Partition,
+                                uint nbr_parties)
+{
+    /*
+     * Principe : distribution des sommets de la première partie en plusieurs autres parties
+     * Le partitionnement étant pseudo aléatoire il n'y a pas de contrainte stricte sur le nombre
+     * de sommets par partie
+     */
+
+
+    uint size = Partition.at(0)->size();
+    uint cpt_sommets=1;
+    int val;
+    uint cpt;
+
+    if(nbr_parties==size){
+        for(uint i = 0; i < nbr_parties;i++){
+            if(Partition.at(0)->size()!=1)
+            {
+                val=rand_fini(0,Partition.at(0)->size()-1);//tirage aléatoire d'un sommets
+            }
+            else
+                val=0;
+
+            int vertex = Partition.at(0)->at(val);
+            Entiers *part = new Entiers();
+            part->push_back(vertex);// ajout du sommet tiré
+            suprim_val(*Partition.at(0),vertex);//suppression du sommet dans la premiere partie
+
+        }
+    }
+    /*
+     * Boucle sur le nombre de partie à réaliser
+     */
+    for(uint i = 0; i < nbr_parties-1;i++){
+        if(Partition.at(0)->size()!=1)
+        {
+            val=rand_fini(0,Partition.at(0)->size()-1);//tirage aléatoire d'un sommets
+        }
+        else
+            val=0;
+        int vertex = Partition.at(0)->at(val);
+        /*
+         * Initialisation d'un pointeur sur un vecteur d'entier, dans notre cas
+         * la n+1 ième partie de la partition
+         */
+        Entiers *part = new Entiers();
+        part->push_back(vertex);// ajout du sommet tiré
+        suprim_val(*Partition.at(0),vertex);//suppression du sommet dans la premiere partie
+        cpt=1;
+
+        /*
+         * Pour chaque element de la nouvelle partie faire
+         */
+        for(uint j = 0; j<part->size();j++){
+            /*
+             * Détermination des voisins de chacun des sommets de cette nouvelle
+             * partie et ajoue de ce voisin si celui-ci est présent dans la première partie (Partition[0])
+             */
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+tie(neighbourIt, neighbourEnd) = adjacent_vertices(part->at(j),*g);
+            for (; neighbourIt != neighbourEnd; ++neighbourIt){
+                if(In_tab(*Partition.at(0),*neighbourIt)==1){
+                    // std::cout<<"le voisin déplacé est : "<<*neighbourIt<<std::endl;
+                    part->push_back(*neighbourIt);
+                    cpt_sommets++;
+                    suprim_val(*Partition.at(0),*neighbourIt);
+                    cpt++;
+                }
+                /*
+                 * Si le nombre moyen de sommets est atteind dans la partie on sort de la boucle des voisins
+                 * Même chose si l'on a rencontré le nombre total de sommets
+                 */
+                if(cpt==(size/nbr_parties)+1)
+                    break;
+                if(cpt_sommets==size)
+                    break;
+            }
+
+            /*
+             * Même chose
+             */
+            if(cpt==(size/nbr_parties)+1)
+                break;
+            if(cpt_sommets==size)
+                break;
+        }
+        Partition.push_back(part);// ajoue de la nouvelle partie à la partition
+        if(cpt_sommets==size)
+            break;
+    }
+}
+
+EntiersEntiers Random_equal_weight_partitioning(UnorientedGraph *g,
+                                uint parts_number)
+{
+	EntiersEntiers Partition;
+	Entiers random_order =  Random_Sort_Vector(num_vertices(*g));
+	uint cpt = 0;
+
+	for(uint j = 0 ; j < parts_number ; j++){
+		Entiers *part = new Entiers();
+		Partition.push_back(part);
+	}
+
+	for(uint id = 0; id < random_order.size(); id++){
+		Partition.at(cpt)->push_back(random_order.at(id));
+		cpt++;
+		if(cpt == parts_number)
+			cpt = 0;
+	}
+
+	for(uint i = 0 ; i < Partition.size() ; i++){
+		sort(Partition.at(i)->begin(),Partition.at(i)->end());
+	}
+
+	return Partition;
+}
+
+EntiersEntiers Random_partitioning(UnorientedGraph *g,
+                                uint parts_number)
+{
+	EntiersEntiers Partition;
+	uint nbr_vertices = num_vertices(*g);
+	Entiers random_order =  Random_Sort_Vector(nbr_vertices);
+	uint cpt = 0;
+
+	std::vector<int> taille;
+
+	int tmp_size = nbr_vertices;
+	for(uint i = 0; i < parts_number - 1; i++){
+		int t1;
+		if(parts_number < 10){
+			if(floor(tmp_size*0.5/10) != 0)
+				t1 = rand_fini(floor(tmp_size*0.5/100), floor(tmp_size*(60-10*i/2)/100));
+			else
+				t1 = rand_fini(1, floor(tmp_size*(60-10*i/2)/100));
+		}else{
+			if(floor(tmp_size*0.5/100) != 0)
+				t1 = rand_fini(floor(tmp_size*0.5/100), floor(tmp_size*(60-10*i/4)/100));
+			else
+				t1 = rand_fini(1, floor(tmp_size*(60-10*i/4)/100));
+		}
+		tmp_size -= t1;
+		taille.push_back(t1);
+	}
+
+	taille.push_back(tmp_size);
+
+	for(uint id_size = 0; id_size < taille.size(); id_size ++){
+		Entiers *part = new Entiers();
+		uint cpt_taille = 0;
+		while(cpt_taille < taille.at(id_size)){
+			part->push_back(random_order.at(cpt));
+			cpt_taille++;
+			cpt++;
+		}
+		Partition.push_back(part);
+	}
+
+	for(uint i = 0 ; i < Partition.size() ; i++){
+		sort(Partition.at(i)->begin(),Partition.at(i)->end());
+	}
+
+	return Partition;
+}
+
+void Coarsening_Phase(Base_Graph &baseg, ListEntiersEntiers &liste_corr,
+					  uint niveau, int nbr_vertex,
+					  std::string parameter){
+	uint cpt = 0;
+	bool stop = false;
+
+    while(!stop){
+    	if(parameter == "HEM")
+			stop = contraction_HEM(baseg.at(cpt), baseg,
+									liste_corr, niveau, nbr_vertex);
+		else if(parameter == "HEM_degree")
+			stop = contraction_HEM_degree(baseg.at(cpt), baseg,
+									liste_corr, niveau, nbr_vertex);
+    	else
+    		stop = contraction_Random_Maching(baseg.at(cpt), baseg,
+									liste_corr, niveau, nbr_vertex);
+        cpt++;
+    }
+    // std::cout<<std::endl;
+
+}
+
+EntiersEntiers Partitioning_Phase(const Base_Graph &baseg,
+					const std::vector<uint> &numeric_parameters,
+					const std::vector<std::string> &parameters,
+					int distance){
+
+    EntiersEntiers Partition;
+    if(parameters.at(1) == "gggp" || parameters.at(1) == "ggp"){
+		Entiers *part = new Entiers();
+		for(uint i = 0; i<num_vertices(*baseg.at(baseg.size() - 1)); i++)
+			part->push_back(i);
+		Partition.push_back(part);
+		bissectionRec(baseg.at(baseg.size()-1), Partition,
+					  numeric_parameters.at(1), parameters.at(3),
+					  numeric_parameters.at(2), parameters.at(1),
+					  distance);
+    }
+    else if(parameters.at(1) == "rand")
+    	Partition = Random_partitioning(baseg.at(baseg.size()-1),
+										numeric_parameters.at(1));
+	else
+		Partition = Random_equal_weight_partitioning(baseg.at(baseg.size()-1),
+										numeric_parameters.at(1));
+
+	return Partition;
+
+}
+
+void Uncoarsening_Phase(const Base_Graph &baseg,
+						EntiersEntiers &Partition,
+						const std::vector<std::string> &parameters,
+						ListEntiersEntiers &liste_corr,
+						double poids_moy, bool rec){
+
+    ListEntiersEntiers::iterator lit(liste_corr.end());
+    bool proj;
+    uint taille_list = liste_corr.size();
+    if(liste_corr.size()==0){
+    	taille_list = 1;
+    	proj = true;
+    }
+    else{
+    	lit--;
+    	proj = false;
+    }
+
+	std::vector<const char* > nom;
+	std::vector<const char* > nom_a;
+	if(rec){
+		const char * tmp_nom1 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_1.txt";
+		nom.push_back(tmp_nom1);
+		const char * tmp_nom_a1 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_1.txt";
+		nom_a.push_back(tmp_nom_a1);
+		const char * tmp_nom2 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_2.txt";
+		nom.push_back(tmp_nom2);
+		const char * tmp_nom_a2 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_2.txt";
+		nom_a.push_back(tmp_nom_a2);
+		const char * tmp_nom3 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_3.txt";
+		nom.push_back(tmp_nom3);
+		const char * tmp_nom_a3 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_3.txt";
+		nom_a.push_back(tmp_nom_a3);
+		const char * tmp_nom4 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_4.txt";
+		nom.push_back(tmp_nom4);
+		const char * tmp_nom_a4 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_4.txt";
+		nom_a.push_back(tmp_nom_a4);
+		const char * tmp_nom5 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_5.txt";
+		nom.push_back(tmp_nom5);
+		const char * tmp_nom_a5 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_5.txt";
+		nom_a.push_back(tmp_nom_a5);
+		const char * tmp_nom6 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_6.txt";
+		nom.push_back(tmp_nom6);
+		const char * tmp_nom_a6 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_6.txt";
+		nom_a.push_back(tmp_nom_a6);
+		const char * tmp_nom7 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_7.txt";
+		nom.push_back(tmp_nom7);
+		const char * tmp_nom_a7 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_7.txt";
+		nom_a.push_back(tmp_nom_a7);
+		const char * tmp_nom8= "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_8.txt";
+		nom.push_back(tmp_nom8);
+		const char * tmp_nom_a8 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_8.txt";
+		nom_a.push_back(tmp_nom_a8);
+		const char * tmp_nom9 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_9.txt";
+		nom.push_back(tmp_nom9);
+		const char * tmp_nom_a9 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_9.txt";
+		nom_a.push_back(tmp_nom_a9);
+		const char * tmp_nom10 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_10.txt";
+		nom.push_back(tmp_nom10);
+		const char * tmp_nom_a10 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_10.txt";
+		nom_a.push_back(tmp_nom_a10);
+		const char * tmp_nom11 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_11.txt";
+		nom.push_back(tmp_nom11);
+		const char * tmp_nom_a11 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_11.txt";
+		nom_a.push_back(tmp_nom_a11);
+		const char * tmp_nom12 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_12.txt";
+		nom.push_back(tmp_nom12);
+		const char * tmp_nom_a12 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_12.txt";
+		nom_a.push_back(tmp_nom_a12);
+		const char * tmp_nom13 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_13.txt";
+		nom.push_back(tmp_nom13);
+		const char * tmp_nom_a13 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_13.txt";
+		nom_a.push_back(tmp_nom_a13);
+		const char * tmp_nom14 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_14.txt";
+		nom.push_back(tmp_nom14);
+		const char * tmp_nom_a14 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_14.txt";
+		nom_a.push_back(tmp_nom_a14);
+		const char * tmp_nom15 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_15.txt";
+		nom.push_back(tmp_nom15);
+		const char * tmp_nom_a15 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_15.txt";
+		nom_a.push_back(tmp_nom_a15);
+		const char * tmp_nom16 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_16.txt";
+		nom.push_back(tmp_nom16);
+		const char * tmp_nom_a16 = "../../sortie_graphe/Tests/Graphes/Multiniveau/txt/projection_partition_affine_16.txt";
+		nom_a.push_back(tmp_nom_a16);
+	}
+
+    for(uint y =0 ; y < taille_list ; y++){
+    	if(!proj){
+    		projection(Partition,lit);
+    		if(rec)
+				Plot_UnorientedGraph_All(baseg.at(baseg.size()-2-y),
+										 Partition,nom.at(y), true);
+
+    		double cut = Cut_cluster(Partition,
+										*baseg.at(baseg.size()-2-y),
+										parameters.at(3));
+    		if(parameters.at(2) == "charge")
+    			Affinage_equilibrage_charge(baseg.at(baseg.size()-2-y),
+										Partition);
+    		else if(parameters.at(2) == "locale"){
+    			Affinage_recherche_locale(baseg.at(baseg.size()-2-y),
+										Partition, cut, parameters.at(3));}
+    		else
+    			Affinache_gain_diff(baseg.at(baseg.size()-2-y),
+										Partition, cut,
+										parameters.at(3), poids_moy);
+
+			if(rec)
+				Plot_UnorientedGraph_All(baseg.at(baseg.size()-2-y),
+										Partition, nom_a.at(y), true);
+
+    		lit--;
+    	}
+
+    }
+}
+
+/* std::vector<std::string> parameters :
+ * 0 -> contraction    : nom de la méthode de contraction
+ * 1 -> type_methode   : nom de la méthode de partitionnement
+ * 2 -> choix_affinage : nom de la méthode d'affinage
+ * 3 -> type_cut       : nom de la fonction objectif étudiée
+ *
+ * std::vector<uint> numeric_parameters :
+ * 0 -> niveau_contraction : niveau de contraction à atteindre
+ * 1 -> nbr_parties        : nombre de parties de la partition
+ * 2 -> nbr_tirage         : nombre de tirage de sommet de depart
+ * 3 -> distance           : distance minimum de selection de sommet
+ * 							 de depart par default -1
+ */
+
+OrientedGraphs Multiniveau(OrientedGraph *go,
+                           const std::vector<uint> &numeric_parameters,
+                           const std::vector<std::string> &parameters,
+                           Edges& /* edge_partie */,
+                           OutputEdgeList& outputedgelist,
+                           InputEdgeList& inputedgelist,
+                           Connections& connections,
+                           bool rec, int distance)
+{
+    // boost::timer t;
+    // double t1, t2, t3, t4;
+    UnorientedGraph *g = new UnorientedGraph();
+UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+	make_unoriented_graph(*go, *g);
+	UnorientedGraph *copie = new UnorientedGraph();
+	boost::copy_graph(*g,*copie);
+	//Plot_UnorientedGraph(copie,"lifegame.txt");
+    Base_Graph baseg;
+    //baseg.push_back(g);
+    ListEntiersEntiers liste_corr;
+    OrientedGraphs Graphes;
+    int val_cpt = num_vertices(*g);
+    bool time = true;
+
+
+    /*Eigen::MatrixXd Madj = adjacence_matrix(g);
+	std::cout << Madj << std::endl << std::endl;*/
+
+    if(numeric_parameters.at(0) != val_cpt && parameters.at(1) != "rand" && parameters.at(1) != "rande"){
+
+		simple_graph(copie);
+		baseg.push_back(copie);
+		//Plot_UnorientedGraph(copie,"lifegame2.txt");
+		Coarsening_Phase(baseg, liste_corr, numeric_parameters.at(0), val_cpt, parameters.at(0));
+
+	    if(rec){
+			std::ofstream GRAPHp ("../../sortie_graphe/Tests/Graphes/Bissection/poids_graphe.txt", std::ios::out);
+			GRAPHp<<"Poids du graphe contracté : "<<std::endl;
+			tie(vertexIt, vertexEnd) = vertices(*baseg.at(baseg.size()-1));
+			for (; vertexIt != vertexEnd; ++vertexIt) {
+				GRAPHp<<(*baseg.at(baseg.size()-1))[*vertexIt]._index<<" --> "<<(*baseg.at(baseg.size()-1))[*vertexIt]._weight<<std::endl;;
+			}
+			GRAPHp<<"}";
+			GRAPHp.close();
+		}
+
+		// if(time){
+		// 	t2 = t.elapsed();
+		// 	// std::cout << "C : " << t2 << " ; ";
+		// }
+
+	    if(rec)
+			Plot_UnorientedGraph(baseg.at(baseg.size()-1),"../../sortie_graphe/Tests/Graphes/Multiniveau/txt/contraction_final.txt");
+
+		UnorientedGraph copy_graph;
+		boost::copy_graph(*baseg.at(baseg.size()-1),copy_graph);
+
+		EntiersEntiers Partition = Partitioning_Phase(baseg,
+							numeric_parameters, parameters, distance);
+
+	    // if(time){
+	    //     	t3 = t.elapsed();
+	    //     	// std::cout << "P : " << (t3 - t2) << " ; ";
+	    // }
+
+	    if(rec)
+			Plot_UnorientedGraph_All(&copy_graph,Partition,"../../sortie_graphe/Tests/Graphes/Multiniveau/txt/contraction_final_partition.txt", true);
+
+		double poids_moy = 0.;
+		for(uint i =0; i < Partition.size(); i++)
+			poids_moy += Cluster_Weight(copy_graph,*Partition.at(i));
+		poids_moy/=Partition.size();
+		poids_moy = -1; /*poids faible*/
+
+		Uncoarsening_Phase(baseg, Partition, parameters,
+								  liste_corr, poids_moy, rec);
+
+	    //     if(time){
+	    //     	t4 = t.elapsed();
+	    //     	// std::cout << "A : " << (t4 - t3) << " ; "<<std::endl;
+	    // }
+
+	    for(uint si = 0; si < Partition.size(); si++){
+			// std::cout<<Partition.at(si)->size()<<std::endl;
+		}
+		// std::cout<<std::endl;
+
+	    double ratio_cut = Cut_cluster(Partition, *g, parameters.at(3));
+	    // std::cout<<"Ratio : "<<ratio_cut<<std::endl;
+
+		Graphes = Graph_Partition(Partition, go, g, outputedgelist,
+	                              inputedgelist, connections);
+	    if(rec)
+			Plot_OrientedGraph_All(go,Partition,"../../sortie_graphe/Tests/Graphes/Multiniveau/txt/résultat_partitionnement.txt", true);
+
+		delete g;
+		for(uint it = 0 ; it < Partition.size(); it++ )
+		{
+			delete Partition.at(it);
+		}
+	}else{
+		UnorientedGraph *copie_g = new UnorientedGraph();
+		boost::copy_graph(*g,*copie_g);
+		baseg.push_back(g);
+
+		EntiersEntiers Partition = Partitioning_Phase(baseg,
+								   numeric_parameters, parameters,
+								   distance);
+
+	    //     if(time){
+	    //         t1 = t.elapsed();
+	    //     	// std::cout << "P : " << t1 << " ; "<<std::endl;
+	    // }
+
+	    for(uint si = 0; si < Partition.size(); si++){
+			// std::cout<<Partition.at(si)->size()<<std::endl;
+		}
+		// std::cout<<std::endl;
+
+	    double ratio_cut = Cut_cluster(Partition, *copie_g, parameters.at(3));
+	    // std::cout<<"Ratio : "<<ratio_cut<<std::endl;
+
+		Graphes = Graph_Partition(Partition, go, copie_g,
+								  outputedgelist, inputedgelist,
+								  connections);
+
+        if(rec)
+			Plot_OrientedGraph_All(go,Partition,"../../sortie_graphe/Tests/Graphes/Multiniveau/txt/résultat_partitionnement.txt", true);
+
+		delete copie_g;
+		for(uint it = 0 ; it < Partition.size(); it++ )
+		{
+			delete Partition.at(it);
+		}
+	}
+
+    for(ListEntiersEntiers::iterator it = liste_corr.begin(); it != liste_corr.end(); it++)
+    {
+        for(EntiersEntiers::iterator it1 = (*it)->begin(); it1 != (*it)->end(); it1++)
+        {
+            delete *it1;
+            *it1 = NULL;
+        }
+        delete *it;
+        *it = NULL;
+    }
+
+    for(Base_Graph::iterator it = baseg.begin(); it != baseg.end(); it++)
+    {
+        delete *it;
+        *it = NULL;
+    }
+
+    return Graphes;
+}
+
+void Optimisation_method_neighbour(UnorientedGraph *g,
+			EntiersEntiers &Partition, int index_partition,
+			int nbr_tirage, const std::string &name_cut,
+			const std::string &name_strat){
+
+	/*Initialisation des parametres*/
+	Entiers *part2_cons = new Entiers();
+	Entiers *part_cour_cons = new Entiers();
+	double cut = 1000000000.;
+
+	Entiers Random_list_vertices =  Random_Sort_Vector(Partition.at(index_partition)->size());
+
+	if(Partition.at(index_partition)->size()< nbr_tirage)
+		nbr_tirage = Partition.at(index_partition)->size();
+
+	/*Boucle de conservation de la meilleure bissection*/
+	for(int k = 0; k<nbr_tirage; k++){
+		Entiers *part2 = new Entiers();
+		Entiers *tmp_part = new Entiers();
+		double new_cut;
+
+		/*Recopie de la partie faisant l'objet de la bissection */
+		for(uint t=0; t<Partition.at(index_partition)->size();t++)
+			tmp_part->push_back(Partition.at(index_partition)->at(t));
+
+		if(name_strat == "gggp")
+			gggp_pond(g, tmp_part, part2, Partition,
+					  Random_list_vertices.at(k), index_partition,
+					  name_cut , -1);
+		else if(name_strat == "ggp")
+			ggp(g, tmp_part, part2, Partition,
+					  Random_list_vertices.at(k), index_partition ,-1);
+		// else
+		// 	std::cout<<"Nom de stratégie de partitionnement non valide ! "<<std::endl;
+
+		new_cut = Best_Cut_cluster(Partition, tmp_part,
+					  part2, index_partition, *g, name_cut);
+
+		/*conservation de l'information en cas d'amélioration
+		 * de la contrainte*/
+		if(new_cut<cut){
+			cut = new_cut;
+			delete part2_cons;
+			delete part_cour_cons;
+			part2_cons = part2;
+			part_cour_cons = tmp_part;
+		}
+		else{
+			delete tmp_part;
+			delete part2;
+		}
+	}
+
+	for (uint i=0; i<part_cour_cons->size();i++)
+    {
+        for (uint j=0; j<part2_cons->size();j++)
+        {
+            remove_edge(part_cour_cons->at(i),part2_cons->at(j),*g);
+        }
+    }
+
+	/*Modification des informations*/
+	delete Partition.at(index_partition);
+	Partition.at(index_partition)=part_cour_cons;
+	Partition.push_back(part2_cons);
+}
+
+void Optimisation_method_neighbour_distance(UnorientedGraph *g,
+			EntiersEntiers &Partition, int index_partition,
+			int nbr_tirage, int distance, const std::string &name_cut,
+			const std::string &name_strat){
+
+	/*Initialisation des parametres*/
+	Entiers *part2_cons = new Entiers();
+	Entiers *part_cour_cons = new Entiers();
+	double cut=1000000000.;
+	int val;
+
+	std::list<int> vertex_list;
+	for(uint verx =0; verx<Partition.at(index_partition)->size(); verx++){
+		vertex_list.push_back(Partition.at(index_partition)->at(verx));
+	}
+
+	if(Partition.at(index_partition)->size()< nbr_tirage)
+		nbr_tirage = Partition.at(index_partition)->size();
+
+	/*Boucle de conservation de la meilleure bissection*/
+	for(int k = 0; k<nbr_tirage; k++){
+		std::list<int>::iterator Iter;
+		if(vertex_list.size()!=0){
+			Iter = vertex_list.begin();
+			for(int i = 0; i<rand_fini(0,vertex_list.size()); i++)
+				Iter++;
+			val = *Iter;
+			tirage_distance(g, *Iter, vertex_list, distance);
+		}
+		else{
+			break;
+		}
+
+		Entiers *part2 = new Entiers();
+		Entiers *tmp_part = new Entiers();
+		double new_cut;
+
+		/*Recopie de la partie faisant l'objet de la bissection*/
+		for(uint t=0; t<Partition.at(index_partition)->size();t++)
+			tmp_part->push_back(Partition.at(index_partition)->at(t));
+
+		if(name_strat == "gggp")
+			gggp_pond(g, tmp_part, part2, Partition, val,
+					  index_partition, name_cut, distance);
+		else if(name_strat == "ggp")
+			ggp(g, tmp_part, part2, Partition, val,
+					  index_partition, distance);
+		// else
+		// 	std::cout<<"Nom de stratégie de partitionnement non valide ! "<<std::endl;
+
+		new_cut = Best_Cut_cluster(Partition, tmp_part, part2,
+					  index_partition, *g,name_cut);
+
+		if(new_cut<cut){
+			cut = new_cut;
+			delete part2_cons;
+			delete part_cour_cons;
+			part2_cons = part2;
+			part_cour_cons = tmp_part;
+		}
+		else{
+			delete tmp_part;
+			delete part2;
+		}
+	}
+
+	for (uint i=0; i<part_cour_cons->size();i++)
+    {
+        for (uint j=0; j<part2_cons->size();j++)
+        {
+			remove_edge(part_cour_cons->at(i), part2_cons->at(j), *g);
+        }
+    }
+
+	/*Modification des informations*/
+	delete Partition.at(index_partition);
+	Partition.at(index_partition)=part_cour_cons;
+	Partition.push_back(part2_cons);
+}
+
+void Optimisation_method_neighbour_degree(UnorientedGraph *g,
+			EntiersEntiers &Partition, int index_partition,
+			const std::string &name_cut,
+			const std::string &name_strat){
+
+	std::vector<double> vertex_degree;
+	Entiers *part2 = new Entiers();
+
+	for(uint i =0; i<Partition.at(index_partition)->size(); i++)
+		vertex_degree.push_back(Degree(*g,
+								Partition.at(index_partition)->at(i)));
+
+
+	uint best_cpt = 0;
+	double  best_degree = vertex_degree.at(0);
+
+	for(uint i =1; i<vertex_degree.size(); i++){
+		if(vertex_degree.at(i)>best_degree){
+			best_degree = vertex_degree.at(i);
+			best_cpt = i;
+		}
+	}
+
+	if(name_strat == "gggp")
+		gggp_pond(g, Partition.at(index_partition), part2,
+				  Partition, best_cpt, index_partition,
+				  name_cut, -1);
+	else if(name_strat == "ggp")
+		ggp(g ,Partition.at(index_partition), part2, Partition,
+				  best_cpt, index_partition, -1);
+	// else
+	// 	std::cout<<"Nom de stratégie de partitionnement non valide ! "<<std::endl;
+
+	for (uint i=0; i<Partition.at(index_partition)->size();i++){
+        for (uint j=0; j<part2->size();j++){
+			remove_edge(Partition.at(index_partition)->at(i),
+						part2->at(j), *g);
+        }
+    }
+
+	Partition.push_back(part2);
+}
+
+void Optimisation_method_neighbour_minweight(UnorientedGraph *g,
+					EntiersEntiers &Partition, int index_partition,
+					const std::string &name_cut,
+					const std::string &name_strat){
+
+	std::vector<double> vertex_weight;
+	Entiers *part2 = new Entiers();
+
+	for(uint i =0; i<Partition.at(index_partition)->size(); i++){
+		vertex_weight.push_back((*g)[Partition.at(index_partition)->at(i)]._weight);
+	}
+
+	uint best_cpt = 0;
+	double  best_weight = vertex_weight.at(0);
+
+	for(uint i =1; i<vertex_weight.size(); i++){
+		if(vertex_weight.at(i)>best_weight){
+			best_weight = vertex_weight.at(i);
+			best_cpt = i;
+		}
+	}
+
+	if(name_cut == "ratio"){
+		int tmp_best_cpt;
+		tmp_best_cpt = Partition.at(index_partition)->at(best_cpt);
+		best_cpt = tmp_best_cpt;
+	}
+
+	if(name_strat == "gggp"){
+		gggp_pond(g, Partition.at(index_partition), part2,
+					 Partition, best_cpt, index_partition,
+					 name_cut, -1);
+	} else if(name_strat == "ggp"){
+		ggp(g, Partition.at(index_partition), part2,
+					 Partition, best_cpt, index_partition, -1);
+	} else {
+		// std::cout<<"Nom de stratégie de partitionnement non valide ! "<<std::endl;
+	}
+
+	for (uint i=0; i<Partition.at(index_partition)->size();i++)
+    {
+        for (uint j=0; j<part2->size();j++)
+        {
+			remove_edge(Partition.at(index_partition)->at(i),
+					 part2->at(j), *g);
+        }
+    }
+
+	Partition.push_back(part2);
+
+}
+
+void tirage_distance(UnorientedGraph *g, int tirage,
+						std::list<int> &vertex_list, int distance){
+	std::vector<std::list<int> > vertex_delete;
+	std::list<int> liste1;
+	std::list<int> vd;
+
+	liste1.push_back(tirage);
+	vertex_delete.push_back(liste1);
+
+	for(int i=0; i<distance; i++){
+		std::list<int> liste_tmp;
+		std::list<int>::iterator Ite_tmp;
+		for(Ite_tmp = vertex_delete.at(i).begin();
+								Ite_tmp != vertex_delete.at(i).end();
+								Ite_tmp ++){
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+
+                    tie(neighbourIt, neighbourEnd) =
+								adjacent_vertices(*Ite_tmp,*g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				liste_tmp.push_back(*neighbourIt);
+			}
+		}
+		liste_tmp.sort();
+		liste_tmp.unique();
+		vertex_delete.push_back(liste_tmp);
+	}
+
+	for(int index = 0; index < vertex_delete.size(); index ++){
+		vd.merge(vertex_delete.at(index));
+	}
+	vd.unique();
+
+	std::list<int>::iterator Ite;
+	for(Ite = vd.begin(); Ite != vd.end(); Ite ++){
+		vertex_list.remove(*Ite);
+	}
+}
+
 } } } // namespace paradevs tests boost_graph
 
 #endif

+ 0 - 1453
src/tests/boost_graph/partitioning/graph_build.cpp

@@ -1,1453 +0,0 @@
-/**
- * @file tests/boost_graph/partitioning/graph_build.cpp
- * @author The PARADEVS Development Team
- * See the AUTHORS or Authors.txt file
- */
-
-/*
- * PARADEVS - the multimodeling and simulation environment
- * This file is a part of the PARADEVS environment
- *
- * Copyright (C) 2013-2015 ULCO http://www.univ-litoral.fr
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <tests/boost_graph/partitioning/graph_build.hpp>
-#include <iostream>
-
-//#include <tests/corsen/lib/Corsen.hpp>
-
-namespace paradevs { namespace tests { namespace boost_graph {
-
-void build_graph(OrientedGraph& og, unsigned int edge_number)
-{
-
-	if(edge_number == 11){
-		vertex_to v0 = boost::add_vertex(og);
-		vertex_to v1 = boost::add_vertex(og);
-		vertex_to v2 = boost::add_vertex(og);
-		vertex_to v3 = boost::add_vertex(og);
-		vertex_to v4 = boost::add_vertex(og);
-		vertex_to v5 = boost::add_vertex(og);
-		vertex_to v6 = boost::add_vertex(og);
-		vertex_to v7 = boost::add_vertex(og);
-		vertex_to v8 = boost::add_vertex(og);
-		vertex_to v9 = boost::add_vertex(og);
-		vertex_to v10 = boost::add_vertex(og);
-
-		add_edge(v1, v0, EdgeProperties(1), og);
-		add_edge(v2, v0, EdgeProperties(1), og);
-		add_edge(v3, v0, EdgeProperties(1), og);
-		add_edge(v1, v2, EdgeProperties(1), og);
-		add_edge(v4, v1, EdgeProperties(1.), og);
-		add_edge(v5, v1, EdgeProperties(1.), og);
-		add_edge(v6, v1, EdgeProperties(1.), og);
-		add_edge(v6, v2, EdgeProperties(1.), og);
-		add_edge(v2, v3, EdgeProperties(1.), og);
-		add_edge(v9, v3, EdgeProperties(1.), og);
-		add_edge(v10, v3, EdgeProperties(1.), og);
-		add_edge(v4, v5, EdgeProperties(1), og);
-		add_edge(v5, v6, EdgeProperties(1), og);
-		add_edge(v7, v4, EdgeProperties(1.), og);
-		add_edge(v8, v4, EdgeProperties(1.), og);
-		add_edge(v7, v8, EdgeProperties(1), og);
-		add_edge(v9, v10, EdgeProperties(1.), og);
-
-		og[v6] = VertexProperties(6, 1, NORMAL_PIXEL);
-		og[v8] = VertexProperties(8, 1., NORMAL_PIXEL);
-		og[v10] = VertexProperties(10, 1, NORMAL_PIXEL);
-		og[v0] = VertexProperties(0, 1, NORMAL_PIXEL);
-		og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
-		og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
-		og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
-		og[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
-		og[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
-		og[v7] = VertexProperties(7, 1., TOP_PIXEL);
-		og[v9] = VertexProperties(9, 1., TOP_PIXEL);
-
-	} else if(edge_number == 38){
-
-		vertex_to v0 = boost::add_vertex(og);
-		vertex_to v1 = boost::add_vertex(og);
-		vertex_to v2 = boost::add_vertex(og);
-		vertex_to v3 = boost::add_vertex(og);
-		vertex_to v4 = boost::add_vertex(og);
-		vertex_to v5 = boost::add_vertex(og);
-		vertex_to v6 = boost::add_vertex(og);
-		vertex_to v7 = boost::add_vertex(og);
-		vertex_to v8 = boost::add_vertex(og);
-		vertex_to v9 = boost::add_vertex(og);
-		vertex_to v10 = boost::add_vertex(og);
-		vertex_to v11 = boost::add_vertex(og);
-		vertex_to v12 = boost::add_vertex(og);
-		vertex_to v13 = boost::add_vertex(og);
-		vertex_to v14 = boost::add_vertex(og);
-		vertex_to v15 = boost::add_vertex(og);
-		vertex_to v16 = boost::add_vertex(og);
-		vertex_to v17 = boost::add_vertex(og);
-		vertex_to v18 = boost::add_vertex(og);
-		vertex_to v19 = boost::add_vertex(og);
-		vertex_to v20 = boost::add_vertex(og);
-		vertex_to v21 = boost::add_vertex(og);
-		vertex_to v22 = boost::add_vertex(og);
-		vertex_to v23 = boost::add_vertex(og);
-		vertex_to v24 = boost::add_vertex(og);
-		vertex_to v25 = boost::add_vertex(og);
-		vertex_to v26 = boost::add_vertex(og);
-		vertex_to v27 = boost::add_vertex(og);
-		vertex_to v28 = boost::add_vertex(og);
-		vertex_to v29 = boost::add_vertex(og);
-		vertex_to v30 = boost::add_vertex(og);
-		vertex_to v31 = boost::add_vertex(og);
-		vertex_to v32 = boost::add_vertex(og);
-		vertex_to v33 = boost::add_vertex(og);
-		vertex_to v34 = boost::add_vertex(og);
-		vertex_to v35 = boost::add_vertex(og);
-		vertex_to v36 = boost::add_vertex(og);
-		vertex_to v37 = boost::add_vertex(og);
-
-		add_edge(v1, v0, EdgeProperties(1.), og);
-		add_edge(v2, v0, EdgeProperties(1.), og);
-		add_edge(v3, v0, EdgeProperties(1.), og);
-		add_edge(v1, v2, EdgeProperties(1.), og);
-		add_edge(v4, v1, EdgeProperties(1.), og);
-		add_edge(v5, v1, EdgeProperties(1.), og);
-		add_edge(v6, v1, EdgeProperties(1.), og);
-		add_edge(v6, v2, EdgeProperties(1.), og);
-		add_edge(v2, v3, EdgeProperties(1.), og);
-		add_edge(v9, v3, EdgeProperties(1.), og);
-		add_edge(v10, v3, EdgeProperties(1.), og);
-		add_edge(v4, v5, EdgeProperties(1.), og);
-		add_edge(v5, v6, EdgeProperties(1.), og);
-		add_edge(v7, v4, EdgeProperties(1.), og);
-		add_edge(v8, v4, EdgeProperties(1.), og);
-		add_edge(v7, v8, EdgeProperties(1.), og);
-		add_edge(v9, v10, EdgeProperties(1.), og);
-		add_edge(v8, v11, EdgeProperties(1.), og);
-		add_edge(v11, v4, EdgeProperties(1.), og);
-		add_edge(v12, v13, EdgeProperties(1.), og);
-		add_edge(v12, v7, EdgeProperties(1.), og);
-		add_edge(v13, v7, EdgeProperties(1.), og);
-		add_edge(v14, v15, EdgeProperties(1.), og);
-		add_edge(v14, v12, EdgeProperties(1.), og);
-		add_edge(v15, v16, EdgeProperties(1.), og);
-		add_edge(v15, v12, EdgeProperties(1.), og);
-		add_edge(v16, v17, EdgeProperties(1.), og);
-		add_edge(v16, v12, EdgeProperties(1.), og);
-		add_edge(v17, v12, EdgeProperties(1.), og);
-		add_edge(v18, v19, EdgeProperties(1.), og);
-		add_edge(v18, v8, EdgeProperties(1.), og);
-		add_edge(v19, v20, EdgeProperties(1.), og);
-		add_edge(v19, v8, EdgeProperties(1.), og);
-		add_edge(v20, v8, EdgeProperties(1.), og);
-		add_edge(v21, v22, EdgeProperties(1.), og);
-		add_edge(v21, v19, EdgeProperties(1.), og);
-		add_edge(v22, v23, EdgeProperties(1.), og);
-		add_edge(v22, v19, EdgeProperties(1.), og);
-		add_edge(v23, v19, EdgeProperties(1.), og);
-		add_edge(v24, v25, EdgeProperties(1.), og);
-		add_edge(v24, v6, EdgeProperties(1.), og);
-		add_edge(v25, v6, EdgeProperties(1.), og);
-		add_edge(v26, v11, EdgeProperties(1.), og);
-		add_edge(v26, v27, EdgeProperties(1.), og);
-		add_edge(v26, v24, EdgeProperties(1.), og);
-		add_edge(v27, v24, EdgeProperties(1.), og);
-		add_edge(v28, v25, EdgeProperties(1.), og);
-		add_edge(v29, v27, EdgeProperties(1.), og);
-		add_edge(v29, v28, EdgeProperties(1.), og);
-		add_edge(v30, v27, EdgeProperties(1.), og);
-		add_edge(v30, v28, EdgeProperties(1.), og);
-		add_edge(v31, v32, EdgeProperties(1.), og);
-		add_edge(v31, v10, EdgeProperties(1.), og);
-		add_edge(v32, v33, EdgeProperties(1.), og);
-		add_edge(v32, v10, EdgeProperties(1.), og);
-		add_edge(v33, v10, EdgeProperties(1.), og);
-		add_edge(v34, v31, EdgeProperties(1.), og);
-		add_edge(v34, v35, EdgeProperties(1.), og);
-		add_edge(v35, v31, EdgeProperties(1.), og);
-		add_edge(v35, v32, EdgeProperties(1.), og);
-		add_edge(v36, v32, EdgeProperties(1.), og);
-		add_edge(v36, v37, EdgeProperties(1.), og);
-		add_edge(v36, v33, EdgeProperties(1.), og);
-		add_edge(v37, v33, EdgeProperties(1.), og);
-
-		add_edge(v4, v0, EdgeProperties(1.), og);
-		add_edge(v9, v2, EdgeProperties(1.), og);
-		add_edge(v28, v24, EdgeProperties(1.), og);
-		add_edge(v28, v31, EdgeProperties(1.), og);
-		add_edge(v33, v3, EdgeProperties(1.), og);
-		add_edge(v33, v0, EdgeProperties(1.), og);
-		add_edge(v36, v3, EdgeProperties(1.), og);
-		add_edge(v17, v13, EdgeProperties(1.), og);
-		add_edge(v17, v7, EdgeProperties(1.), og);
-		add_edge(v21, v23, EdgeProperties(1.), og);
-		add_edge(v23, v20, EdgeProperties(1.), og);
-		add_edge(v26, v4, EdgeProperties(1.), og);
-
-		og[v6] = VertexProperties(6, 1, NORMAL_PIXEL);
-		og[v8] = VertexProperties(8, 1, NORMAL_PIXEL);
-		og[v10] = VertexProperties(10, 1, NORMAL_PIXEL);
-		og[v0] = VertexProperties(0, 1, NORMAL_PIXEL);
-		og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
-		og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
-		og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
-		og[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
-		og[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
-		og[v7] = VertexProperties(7, 1, NORMAL_PIXEL);
-		og[v9] = VertexProperties(9, 1, TOP_PIXEL);
-		og[v11] = VertexProperties(11, 1, NORMAL_PIXEL);
-		og[v12] = VertexProperties(12, 1, NORMAL_PIXEL);
-		og[v13] = VertexProperties(13, 1, NORMAL_PIXEL);
-		og[v14] = VertexProperties(14, 1, TOP_PIXEL);
-		og[v15] = VertexProperties(15, 1, NORMAL_PIXEL);
-		og[v16] = VertexProperties(16, 1, NORMAL_PIXEL);
-		og[v17] = VertexProperties(17, 1, NORMAL_PIXEL);
-		og[v18] = VertexProperties(18, 1, TOP_PIXEL);
-		og[v19] = VertexProperties(19, 1, NORMAL_PIXEL);
-		og[v20] = VertexProperties(20, 1, NORMAL_PIXEL);
-		og[v21] = VertexProperties(21, 1, TOP_PIXEL);
-		og[v22] = VertexProperties(22, 1, NORMAL_PIXEL);
-		og[v23] = VertexProperties(23, 1, NORMAL_PIXEL);
-		og[v24] = VertexProperties(24, 1, NORMAL_PIXEL);
-		og[v25] = VertexProperties(25, 1, NORMAL_PIXEL);
-		og[v26] = VertexProperties(26, 1, TOP_PIXEL);
-		og[v27] = VertexProperties(27, 1, NORMAL_PIXEL);
-		og[v28] = VertexProperties(28, 1, NORMAL_PIXEL);
-		og[v29] = VertexProperties(29, 1, TOP_PIXEL);
-		og[v30] = VertexProperties(30, 1, TOP_PIXEL);
-		og[v31] = VertexProperties(31, 1, NORMAL_PIXEL);
-		og[v32] = VertexProperties(32, 1, NORMAL_PIXEL);
-		og[v33] = VertexProperties(33, 1, NORMAL_PIXEL);
-		og[v34] = VertexProperties(34, 1, TOP_PIXEL);
-		og[v35] = VertexProperties(35, 1, NORMAL_PIXEL);
-		og[v36] = VertexProperties(36, 1, TOP_PIXEL);
-		og[v37] = VertexProperties(37, 1, NORMAL_PIXEL);
-
-	}else{
-		std::cout<<"Le type de artificiel graphe choisi n'existe pas ! "<<std::endl;
-	}
-}
-
-void modify_file_paths(std::string& absolutePath,
-                       std::vector < std::string* >& files)
-{
-    for (std::vector < std::string* >::iterator it = files.begin();
-         it != files.end(); it++) {
-        (*it)->insert(0, absolutePath);
-    }
-}
-
-void build_graph_cyclique(OrientedGraph& og)
-{
-	vertex_to v0 = boost::add_vertex(og);
-	vertex_to v1 = boost::add_vertex(og);
-	vertex_to v2 = boost::add_vertex(og);
-	vertex_to v3 = boost::add_vertex(og);
-	vertex_to v4 = boost::add_vertex(og);
-	vertex_to v5 = boost::add_vertex(og);
-	vertex_to v6 = boost::add_vertex(og);
-	vertex_to v7 = boost::add_vertex(og);
-	vertex_to v8 = boost::add_vertex(og);
-	vertex_to v9 = boost::add_vertex(og);
-	vertex_to v10 = boost::add_vertex(og);
-
-	add_edge(v0, v1, EdgeProperties(1.), og);
-	add_edge(v0, v2, EdgeProperties(1.), og);
-	add_edge(v0, v3, EdgeProperties(1.), og);
-	add_edge(v1, v3, EdgeProperties(1.), og);
-	add_edge(v2, v1, EdgeProperties(1.), og);
-	add_edge(v2, v3, EdgeProperties(1.), og);
-	add_edge(v2, v4, EdgeProperties(1.), og);
-	add_edge(v2, v5, EdgeProperties(1.), og);
-	add_edge(v2, v7, EdgeProperties(1.), og);
-	add_edge(v2, v9, EdgeProperties(1.), og);
-	add_edge(v3, v4, EdgeProperties(1.), og);
-	add_edge(v3, v5, EdgeProperties(1.), og);
-	add_edge(v3, v7, EdgeProperties(1.), og);
-	add_edge(v3, v9, EdgeProperties(1.), og);
-	add_edge(v4, v6, EdgeProperties(1.), og);
-	add_edge(v5, v4, EdgeProperties(1.), og);
-	add_edge(v5, v6, EdgeProperties(1.), og);
-	add_edge(v6, v7, EdgeProperties(1.), og);
-	add_edge(v7, v8, EdgeProperties(1.), og);
-	add_edge(v7, v10, EdgeProperties(1.), og);
-	add_edge(v8, v9, EdgeProperties(1.), og);
-	add_edge(v8, v10, EdgeProperties(1.), og);
-	add_edge(v9, v10, EdgeProperties(1.), og);
-	add_edge(v10, v0, EdgeProperties(1.), og);
-
-	og[v6] = VertexProperties(6, 1, NORMAL_PIXEL);
-	og[v8] = VertexProperties(8, 1, NORMAL_PIXEL);
-	og[v10] = VertexProperties(10, 1, NORMAL_PIXEL);
-	og[v0] = VertexProperties(0, 1, NORMAL_PIXEL);
-	og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
-	og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
-	og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
-	og[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
-	og[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
-	og[v7] = VertexProperties(7, 1, NORMAL_PIXEL);
-	og[v9] = VertexProperties(9, 1, NORMAL_PIXEL);
-}
-
-void build_example_linked9(OrientedGraph& og)
-{
-	vertex_to v0 = boost::add_vertex(og);
-	vertex_to v1 = boost::add_vertex(og);
-	vertex_to v2 = boost::add_vertex(og);
-	vertex_to v3 = boost::add_vertex(og);
-	vertex_to v4 = boost::add_vertex(og);
-	vertex_to v5 = boost::add_vertex(og);
-	vertex_to v6 = boost::add_vertex(og);
-	vertex_to v7 = boost::add_vertex(og);
-	vertex_to v8 = boost::add_vertex(og);
-	vertex_to v9 = boost::add_vertex(og);
-
-	add_edge(v1, v0, EdgeProperties(1.), og);
-	add_edge(v2, v0, EdgeProperties(1.), og);
-	add_edge(v3, v0, EdgeProperties(1.), og);
-	add_edge(v4, v1, EdgeProperties(1.), og);
-	add_edge(v4, v2, EdgeProperties(1.), og);
-	add_edge(v5, v1, EdgeProperties(1.), og);
-	add_edge(v6, v1, EdgeProperties(1.), og);
-	add_edge(v6, v2, EdgeProperties(1.), og);
-	add_edge(v6, v3, EdgeProperties(1.), og);
-	add_edge(v7, v2, EdgeProperties(1.), og);
-	add_edge(v7, v3, EdgeProperties(1.), og);
-	add_edge(v8, v2, EdgeProperties(1.), og);
-	add_edge(v9, v1, EdgeProperties(1.), og);
-	add_edge(v9, v3, EdgeProperties(1.), og);
-
-	og[v6] = VertexProperties(6, 1, TOP_PIXEL);
-	og[v8] = VertexProperties(8, 1, TOP_PIXEL);
-	og[v0] = VertexProperties(0, 1, NORMAL_PIXEL);
-	og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
-	og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
-	og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
-	og[v4] = VertexProperties(4, 1, TOP_PIXEL);
-	og[v5] = VertexProperties(5, 1, TOP_PIXEL);
-	og[v7] = VertexProperties(7, 1, TOP_PIXEL);
-	og[v9] = VertexProperties(9, 1, TOP_PIXEL);
-}
-/*void build_corsen_graph(OrientedGraph& graph)
-{
-    std::string absolutePath(
-        "/home/eric/vle/vle-labs/paradevs/src/tests/corsen/data_s/");
-    std::string modeFile(".mode");
-    std::string parametersFile("par.txt");
-    std::string elevationFile("alt");
-    std::string outletFile("arbre");
-    std::string layersFile("couche");
-    std::string contextFile("contexte_yar_scenario.xml");
-    std::string slopeFile("pav");
-    std::vector < std::string* > files;
-    Corsen c;
-
-    files.push_back(&parametersFile);
-    files.push_back(&modeFile);
-    files.push_back(&elevationFile);
-    files.push_back(&outletFile);
-    files.push_back(&slopeFile);
-    files.push_back(&contextFile);
-    files.push_back(&layersFile);
-    modify_file_paths(absolutePath, files);
-
-    c.read(files, absolutePath);
-    c.buildGraph();
-
-    const DirectedGraph& g = c.getGraph().graph();
-    std::vector < vertex_t > og_vertex_list;
-    std::vector < vertex_t > dg_vertex_list;
-    std::vector < int > dg_in_vertex_list;
-    DirectedGraph::vertex_iterator it_dg, end_dg;
-
-    tie(it_dg, end_dg) = vertices(g);
-    for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
-        og_vertex_list.push_back(add_vertex(graph));
-        dg_vertex_list.push_back(*it_dg);
-        dg_in_vertex_list.push_back(0);
-    }
-
-    tie(it_dg, end_dg) = vertices(g);
-    for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
-        DirectedGraph::adjacency_iterator neighbour_it, neighbour_end;
-
-        tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_dg, g);
-        for (; neighbour_it != neighbour_end; ++neighbour_it) {
-            uint index = 0;
-
-            while (dg_vertex_list[index] != *neighbour_it) {
-                ++index;
-            }
-            ++dg_in_vertex_list[index];
-            boost::add_edge(og_vertex_list[i], og_vertex_list[index],
-                            EdgeProperties(1.), graph);
-        }
-    }
-
-    tie(it_dg, end_dg) = vertices(g);
-    for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
-        if (dg_in_vertex_list[i] == 0) {
-            graph[og_vertex_list[i]] = VertexProperties(i, 1., TOP_PIXEL);
-        } else {
-            graph[og_vertex_list[i]] = VertexProperties(i, 1., NORMAL_PIXEL);
-        }
-    }
-}*/
-
-void brhtg_source(OrientedGraph *go,int nbr_vertex, int nbr_source, int nbr_v_min, int nbr_v_max, const std::vector<int> &niveau,
-					std::vector<int> &Ram, std::vector<int> &Exu, const std::vector<vertex_to> &Vertexs,
-					int nbr_passe, int nbr_npb){
-
-	uint nbr_voisin;
-
-	int niv=1;
-	for(uint j =0; j<niveau.size()-1; j++){
-		niv *= niveau.at(j);
-	}
-
-	int niv_tot=1;
-	for(uint j =0; j<niveau.size(); j++){
-		niv_tot *= niveau.at(j);
-	}
-
-	for(int b = 0; b<niv; b++){
-		std::vector<uint> branche;
-		int cpt = 0;
-		while(cpt != niveau.at(niveau.size()-1)+1){
-			branche.push_back((b*niveau.at(niveau.size()-1)+cpt)*nbr_npb);
-			cpt++;
-		}
-
-		for(uint i =0; i<branche.size()-1;i++){
-			for(uint j = branche.at(i); j<branche.at(i+1); j++){
-				if(j==branche.at(branche.size()-1)-1){
-					break;
-				}
-				else{
-					nbr_voisin = rand_fini(nbr_v_min, nbr_v_max+1);
-					uint cpt=0;
-					Entiers ensemble;
-					int cpt_nbr_s = 0;
-					while(cpt != nbr_voisin){
-						int val;
-						if(j<branche.at(i)+nbr_source){ // Les sommets sont des sources donc imossible de recevoir des données
-							val = rand_fini(j + 4, j + nbr_v_max + nbr_passe);
-						}
-						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
-							val = rand_fini(branche.at(branche.size()-1)-4, branche.at(branche.size()-1));
-						}
-						else if(j>=branche.at(i)+nbr_npb-nbr_passe && i== (branche.size()-2)){ // Les sommets sont proche de l'exutoire
-							val = rand_fini(j+1,branche.at(branche.size()-1));
-						}
-						else{ // Les sommets sont en plein milieu d'une branche
-							val = rand_fini(j+1, j+nbr_passe);
-						}
-
-						if(In_tab(ensemble,val) != 1){
-							ensemble.push_back(val);
-							boost::add_edge(Vertexs.at(j), Vertexs.at(val), EdgeProperties(1.), *go);
-							cpt++;
-						}
-						else{
-							if((nbr_vertex-j) == cpt)
-								break;
-							else
-								cpt_nbr_s++;
-						}
-
-						if(cpt_nbr_s>2*nbr_passe)
-							break;
-					}
-
-				}
-			}
-		}
-
-		/*for(int i =0; i<branche.size()-1; i++){
-			for(int j = branche.at(i)+nbr_source; j<branche.at(i+1); j++){
-				(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
-			}
-		}
-
-		for(int i =0; i<branche.size()-1; i++){
-			for(int j = branche.at(i); j<branche.at(i)+nbr_source; j++){
-				(*go)[Vertexs.at(j)] = VertexProperties(j, 1, TOP_PIXEL);
-			}
-		}*/
-
-		Ram.push_back((niv_tot+b)*nbr_npb);
-		Exu.push_back(branche.at(branche.size()-1)-1);
-	}
-
-	Ram.push_back(Ram.at(Ram.size()-1)+nbr_npb);
-
-	if(niveau.size()>1){
-		nbr_voisin = 2;
-		for(uint k =0; k<Exu.size(); k++){
-			for(uint l = Exu.at(k)-2; l<Exu.at(k)+1; l++){
-				int cpt=0;
-				Entiers ensemble;
-				int cpt_nbr_s = 0;
-				while(cpt!=nbr_voisin){
-					int val = rand_fini(Ram.at(k),Ram.at(k)+2);
-
-					if(In_tab(ensemble,val)!=1){
-						ensemble.push_back(val);
-						boost::add_edge(Vertexs.at(l), Vertexs.at(val), EdgeProperties(1.), *go);
-						cpt++;
-					}
-					else{
-						if((nbr_vertex-l)==cpt)
-							break;
-						else
-							cpt_nbr_s++;
-					}
-
-					if(cpt_nbr_s>2*nbr_passe)
-						break;
-				}
-			}
-		}
-	}
-}
-
-void brhtg_ramification(OrientedGraph *go, int nbr_vertex, int nbr_v_min, int nbr_v_max, const std::vector<int> &niveau,
-					std::vector<int> &Ram, std::vector<int> &Exu, const std::vector<vertex_to> &Vertexs,
-					int nbr_passe, int nbr_npb){
-
-	int nbr_voisin;
-	int cpt_ram = 1;
-	while(cpt_ram != niveau.size()-1){
-		int niv=1;
-		for(int j =0; j<niveau.size()-1-cpt_ram; j++){
-			niv *= niveau.at(j);
-		}
-
-		int niv_tot=0;
-		for(int i =0; i<=cpt_ram; i++){
-			int tmp_niv_tot=1;
-			for(int j =0; j<niveau.size()-i; j++){
-				tmp_niv_tot *= niveau.at(j);
-			}
-			niv_tot+=tmp_niv_tot;
-		}
-
-		std::vector<std::vector<int> > branche;
-		int cpt_b=0;
-		for(int j = 0; j<(Ram.size()-1)/niveau.at(niveau.size()-1-cpt_ram); j++){
-			std::vector<int> tmp_branche;
-			for(int i =0; i< niveau.at(niveau.size()-1-cpt_ram); i++){
-				tmp_branche.push_back(Ram.at(i+cpt_b));
-			}
-			tmp_branche.push_back(tmp_branche.at(tmp_branche.size()-1)+nbr_npb);
-			branche.push_back(tmp_branche);
-			cpt_b+=niveau.at(niveau.size()-1-cpt_ram);
-		}
-
-		Ram.clear();
-		Exu.clear();
-
-		for(int b = 0; b<niv; b++){
-
-			for(int i =0; i<branche.at(b).size()-1;i++){
-				for(int j = branche.at(b).at(i); j<branche.at(b).at(i+1); j++){
-					if(j==branche.at(b).at(branche.at(b).size()-1)-1){
-						break;
-					}
-					else{
-						nbr_voisin = rand_fini(nbr_v_min, nbr_v_max+1);
-						int cpt=0;
-						Entiers ensemble;
-						int cpt_nbr_s = 0;
-						while(cpt!=nbr_voisin){
-							int val;
-
-							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
-								val = rand_fini(branche.at(b).at(branche.at(b).size()-1)-4, branche.at(b).at(branche.at(b).size()-1));
-							}
-							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
-								val = rand_fini(j+1,branche.at(b).at(branche.at(b).size()-1));
-							}
-							else{ // Les sommets sont en plein milieu d'une branche
-								val = rand_fini(j+1, j+nbr_passe);
-							}
-
-							if(In_tab(ensemble,val)!=1){
-								ensemble.push_back(val);
-								boost::add_edge(Vertexs.at(j), Vertexs.at(val), EdgeProperties(1.), *go);
-								cpt++;
-							}
-							else{
-								if((nbr_vertex-j)==cpt)
-									break;
-								else
-									cpt_nbr_s++;
-							}
-
-							if(cpt_nbr_s>2*nbr_passe)
-								break;
-						}
-
-					}
-				}
-			}
-			Ram.push_back((niv_tot+b)*nbr_npb);
-			Exu.push_back(branche.at(b).at(branche.at(b).size()-1)-1);
-
-			/*for(int y =0; y<branche.at(b).size()-1; y++){
-				for(int x = branche.at(b).at(y); x<branche.at(b).at(y+1); x++){
-					(*go)[Vertexs.at(x)] = VertexProperties(x, 1, NORMAL_PIXEL);
-				}
-			}*/
-		}
-
-		Ram.push_back(Ram.at(Ram.size()-1)+nbr_npb);
-
-		nbr_voisin = 2;
-		for(int k =0; k<Exu.size(); k++){
-			for(int l = Exu.at(k)-1; l<Exu.at(k)+1; l++){
-				int cpt=0;
-				Entiers ensemble;
-				int cpt_nbr_s = 0;
-				while(cpt!=nbr_voisin){
-					int val = rand_fini(Ram.at(k),Ram.at(k)+2);
-
-					if(In_tab(ensemble,val)!=1){
-						ensemble.push_back(val);
-						boost::add_edge(Vertexs.at(l), Vertexs.at(val), EdgeProperties(1.), *go);
-						cpt++;
-					}
-					else{
-						if((nbr_vertex-l)==cpt)
-							break;
-						else
-							cpt_nbr_s++;
-					}
-
-					if(cpt_nbr_s>2*nbr_passe)
-						break;
-				}
-			}
-		}
-		cpt_ram++;
-	}
-}
-
-void brhtg_exutoire(OrientedGraph *go,int nbr_vertex,int nbr_v_min, int nbr_v_max,
-		std::vector<int> &Ram, const std::vector<vertex_to> &Vertexs,
-		int nbr_passe){
-
-	int nbr_voisin;
-	Ram.at(Ram.size()-1)=nbr_vertex;
-
-	for(int i =0; i<Ram.size()-1;i++){
-		for(int j = Ram.at(i); j<Ram.at(i+1); j++){
-			if(j==Ram.at(Ram.size()-1)-1){
-				//(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
-				break;
-			}
-			else{
-				if(Ram.at(i+1)-j<nbr_passe)
-					nbr_voisin = 2;
-				else
-					nbr_voisin = rand_fini(nbr_v_min, nbr_v_max+1);
-				int cpt=0;
-				Entiers ensemble;
-				int cpt_nbr_s = 0;
-				while(cpt!=nbr_voisin){
-					int val;
-
-					if(j>=Ram.at(i+1)-nbr_passe && i!=Ram.size()-2){ // Les sommets sont proche de l'exutoire
-						val = rand_fini(Ram.at(Ram.size()-1)-4,Ram.at(Ram.size()-1));
-					}
-					else if(j>=Ram.at(i+1)-nbr_passe && i==Ram.size()-2){ // Les sommets sont proche de l'exutoire
-						val = rand_fini(j+1,Ram.at(Ram.size()-1));
-					}
-					else{ // Les sommets sont en plein milieu d'une branche
-						val = rand_fini(j+1, j+nbr_passe);
-					}
-
-					if(In_tab(ensemble,val)!=1&& j!=val){
-						ensemble.push_back(val);
-						boost::add_edge(Vertexs.at(j), Vertexs.at(val), EdgeProperties(1.), *go);
-						cpt++;
-					}
-					else{
-						if((nbr_vertex-j)==cpt)
-							break;
-						else
-							cpt_nbr_s++;
-					}
-
-					if(cpt_nbr_s>2*nbr_passe)
-						break;
-				}
-
-			}
-			//(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
-		}
-	}
-}
-
-
-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){
-	std::vector<vertex_to> Vertexs;
-	OrientedGraph::in_edge_iterator ei, edge_end;
-
-	int nbr_npb;
-	int nbr_branche = 0;
-	int nbr_passe = 4;
-
-	for(int i =0; i<nbr_vertex; i++){
-		vertex_to vo = boost::add_vertex(*go);
-		Vertexs.push_back(vo);
-	}
-
-	// Calcul du nombre de branches à partir de l'information des niveaux
-	for(int i =0; i< niveau.size(); i++){
-		int nbr_tmp =1;
-		for(int j =0; j<=i; j++){
-			nbr_tmp *= niveau.at(j);
-		}
-		nbr_branche += nbr_tmp;
-	}
-	// std::cout<<nbr_branche<<std::endl;
-
-	nbr_npb = nbr_vertex/(nbr_branche);
-
-	std::vector<int> Ram;
-	std::vector<int> Exu;
-
-	if(niveau.size()>1){
-	/*
-	 * *** Code Source ***
-	 */
-
-	brhtg_source(go,nbr_vertex,nbr_source,nbr_v_min,nbr_v_max,niveau,Ram,Exu,Vertexs,nbr_passe,nbr_npb);
-
-	/*
-	 * *** Code Ramifications ***
-	 */
-
-	brhtg_ramification(go,nbr_vertex,nbr_v_min,nbr_v_max,niveau,
-			Ram,Exu,Vertexs,nbr_passe,nbr_npb);
-
-	/*
-	 * *** Code Exutoire ***
-	 */
-
-	brhtg_exutoire(go,nbr_vertex,nbr_v_min,nbr_v_max,
-				Ram,Vertexs,nbr_passe);
-
-	} else {
-			brhtg_source(go,nbr_vertex,nbr_source,nbr_v_min,nbr_v_max,niveau,Ram,Exu,Vertexs,nbr_passe,nbr_npb);
-	}
-
-	std::vector < int > dg_in_vertex_list;
-	std::vector <vertex_to> dg_vertex_list;
-	OrientedGraph::vertex_iterator it_dg, end_dg;
-
-	tie(it_dg, end_dg) = vertices(*go);
-	for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
-		dg_in_vertex_list.push_back(0);
-		dg_vertex_list.push_back(*it_dg);
-	}
-
-	tie(it_dg, end_dg) = vertices(*go);
-	for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
-		OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
-
-		tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_dg, *go);
-		for (; neighbour_it != neighbour_end; ++neighbour_it) {
-			uint index = 0;
-
-			while (dg_vertex_list[index] != *neighbour_it) {
-				++index;
-			}
-			++dg_in_vertex_list[index];
-		}
-	}
-
-	int compteur = 0;
-	for(uint i = 0; i<num_vertices(*go); i++){
-		bool indic = false;
-		for(tie(ei,edge_end) = in_edges(i,*go); ei != edge_end; ++ei){
-			indic = true;
-			break;
-		}
-		if(dg_in_vertex_list.at(i) == 0 || indic == false){
-			compteur++;
-			(*go)[i] = VertexProperties(i, 1, TOP_PIXEL);
-		}else{
-			(*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
-		}
-		//std::cout<<(*go)[i]._index<<" "<<indic<<" -> "<<(*go)[i]._type<<std::endl;
-	}
-
-	// std::cout<<"Compteur : "<<compteur<<std::endl;
-}
-
-void build_generator_graph_linked(OrientedGraph *go, int nbr_vertex, int nbr_couche, int nbr_v_min, int nbr_v_max){
-	std::vector<vertex_to> Vertexs;
-	OrientedGraph::in_edge_iterator ei, edge_end;
-
-	for(int i =0; i<nbr_vertex; i++){
-		vertex_to vo = boost::add_vertex(*go);
-		Vertexs.push_back(vo);
-	}
-
-	/*Création du vecteur contenant le nombre de sommets par couche*/
-	int midel_couche = nbr_couche-2;
-	int top_couche;
-	if(nbr_couche>5){
-		top_couche = floor(nbr_vertex/3);//floor(midel_couche/2));
-	}else{
-		top_couche = floor(nbr_vertex/2);
-	}
-	int nbr_vertex_midel_couche = nbr_vertex - top_couche -1;
-	int tmp = 0;
-	std::vector<int> nbr_som_couche;
-	nbr_som_couche.push_back(1);
-
-	for(int i = 1; i <= midel_couche; i++){
-		tmp += i;
-	}
-
-	for(int i = 0; i < midel_couche; i++){
-		nbr_som_couche.push_back(floor((i+1)*nbr_vertex_midel_couche/tmp));
-	}
-
-	nbr_som_couche.push_back(top_couche);
-
-	int sum = 0;
-	for(int i = 0; i < nbr_som_couche.size(); i++){
-		sum += nbr_som_couche.at(i);
-	}
-	int reste = nbr_vertex - sum;
-
-	/*std::cout<<"sum : "<<sum<<std::endl;
-	std::cout<<"midel_couche : "<<midel_couche<<std::endl;
-	std::cout<<"top_couche : "<<top_couche<<std::endl;
-	std::cout<<"nbr_vertex_midel_couche : "<<nbr_vertex_midel_couche<<std::endl;
-	std::cout<<"tmp : "<<tmp<<std::endl;
-	std::cout<<"reste : "<<reste<<std::endl;
-
-	for(int i =0; i < nbr_som_couche.size(); i++){
-		std::cout<<nbr_som_couche.at(i)<<" ";
-	}
-	std::cout<<std::endl;*/
-
-	while(reste != 0){
-		for(int i = 1; i <nbr_som_couche.size(); i++){
-			nbr_som_couche.at(i) += 1;
-			reste --;
-			if(reste == 0){
-				break;
-			}
-		}
-	}
-
-	/*for(int i =0; i < nbr_som_couche.size(); i++){
-		std::cout<<nbr_som_couche.at(i)<<" ";
-	}
-	std::cout<<std::endl;*/
-
-	/*Génération du graphe*/
-	std::vector<int> tab_couche_som;
-	tab_couche_som.push_back(0);
-
-	for(int i =1; i<nbr_som_couche.size(); i++){
-		tab_couche_som.push_back(tab_couche_som.at(i-1)+nbr_som_couche.at(i));
-	}
-
-	/*for(int i =0; i < tab_couche_som.size(); i++){
-		std::cout<<tab_couche_som.at(i)<<" ";
-	}
-	std::cout<<std::endl;*/
-	int nbr_vois = nbr_v_max+2;
-
-	int cpt = 0;
-	for(int i = tab_couche_som.at(tab_couche_som.size()-2)+1; i <= tab_couche_som.at(tab_couche_som.size()-1); i++){
-		std::vector<int> vertex_tmp;
-		int rand = rand_fini(nbr_v_min,nbr_v_max+1);
-		int neigh_cpt = 0;
-		while(neigh_cpt != rand){
-			int val;
-			if(cpt<nbr_vois){
-				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);
-				//std::cout<<"val1 : "<<val<<std::endl;
-			}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)){
-				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);
-				//std::cout<<"val2 : "<<val<<std::endl;
-			}else{
-				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);
-				//std::cout<<"val3 : "<<val<<std::endl;
-			}
-			if(In_tab(vertex_tmp,val) != 1){
-				boost::add_edge(Vertexs.at(i), Vertexs.at(val), EdgeProperties(1.), *go);
-				vertex_tmp.push_back(val);
-				neigh_cpt ++;
-			}
-		}
-		cpt ++;
-	}
-	//std::cout<<"Passage !"<<std::endl;
-
-	for(int j = 2; j < tab_couche_som.size()-1; j++){
-		cpt = 0;
-		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++){
-			std::vector<int> vertex_tmp;
-			int rand = rand_fini(nbr_v_min,nbr_v_max+1);
-			//std::cout<<"rand : "<<rand<<std::endl;
-			int neigh_cpt = 0;
-			while(neigh_cpt != rand){
-				int val;
-				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){
-					if(cpt<nbr_vois){
-						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);
-						//std::cout<<"val1 : "<<val<<std::endl;
-					}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)){
-						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);
-						//std::cout<<"val2 : "<<val<<std::endl;
-					}else{
-						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)){
-							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);
-						}else{
-							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);
-						}
-						//std::cout<<"val3 : "<<val<<std::endl;
-					}
-				}else{
-					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);
-				}
-				//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);
-				if(In_tab(vertex_tmp,val) != 1){
-					boost::add_edge(Vertexs.at(i), Vertexs.at(val), EdgeProperties(1.), *go);
-					vertex_tmp.push_back(val);
-					neigh_cpt ++;
-				}
-			}
-			cpt ++;
-		}
-	}
-	//std::cout<<"Passage2 !"<<std::endl;
-
-	for(int i = tab_couche_som.at(0)+1; i <= tab_couche_som.at(1); i++){
-		//int val = rand_fini(0,2);
-		//if(val == 0){
-			boost::add_edge(Vertexs.at(i), Vertexs.at(0), EdgeProperties(1.), *go);
-		//}
-	}
-	//std::cout<<"Passage3 !"<<std::endl;
-
-	std::vector < int > dg_in_vertex_list;
-	std::vector <vertex_to> dg_vertex_list;
-	OrientedGraph::vertex_iterator it_dg, end_dg;
-
-	tie(it_dg, end_dg) = vertices(*go);
-	for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
-		dg_in_vertex_list.push_back(0);
-		dg_vertex_list.push_back(*it_dg);
-	}
-
-	tie(it_dg, end_dg) = vertices(*go);
-	for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
-		OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
-
-		tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_dg, *go);
-		for (; neighbour_it != neighbour_end; ++neighbour_it) {
-			uint index = 0;
-
-			while (dg_vertex_list[index] != *neighbour_it) {
-				++index;
-			}
-			++dg_in_vertex_list[index];
-		}
-	}
-
-	for(uint i = 0; i<num_vertices(*go); i++){
-		bool indic = false;
-		for(tie(ei,edge_end) = in_edges(i,*go); ei != edge_end; ++ei){
-			indic = true;
-			break;
-		}
-		if(dg_in_vertex_list.at(i) == 0 || indic == false){
-			(*go)[i] = VertexProperties(i, 1, TOP_PIXEL);
-		}else{
-			(*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
-		}
-	}
-}
-
-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){
-	int nbr_vertex = side*side;
-	std::vector<vertex_to> Vertexs;
-	for(int i =0; i<nbr_vertex; i++){
-		vertex_to vo = boost::add_vertex(*go);
-		Vertexs.push_back(vo);
-	}
-
-	if(rec == true){
-		std::ofstream fichier (edge_weight, std::ios::out);
-		for(int i = 0; i<side; i++){
-			for(int j = 0; j<side-1; j++){
-				boost::add_edge(i*side+j, i*side+j+1,EdgeProperties(1), *go);
-				fichier<<i*side+j<<" "<<i*side+j+1<<" "<<1<<" "<<std::endl;
-			}
-		}
-
-		for(int i = 0; i<side-1; i++){
-			for(int j = 0; j<side; j++){
-				boost::add_edge(i*side+j, (i+1)*side+j,EdgeProperties(1), *go);
-				fichier<<i*side+j<<" "<<(i+1)*side+j<<" "<<1<<" "<<std::endl;
-			}
-		}
-		fichier.close();
-	}else{
-		for(int i = 0; i<side; i++){
-			for(int j = 0; j<side-1; j++){
-				boost::add_edge(i*side+j, i*side+j+1,EdgeProperties(1), *go);
-			}
-		}
-
-		for(int i = 0; i<side-1; i++){
-			for(int j = 0; j<side; j++){
-				boost::add_edge(i*side+j, (i+1)*side+j,EdgeProperties(1), *go);
-			}
-		}
-	}
-
-	(*go)[0] = VertexProperties(0, 1, TOP_PIXEL);
-	for(uint i = 1; i<num_vertices(*go); i++){
-			(*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
-	}
-
-	for(int ind=0; ind<vertex_selection.size(); ind++){
-		for(int ind_i = vertex_selection.at(ind).first; ind_i<vertex_selection.at(ind).second+1; ind_i++){
-			if(ind_i != 0)
-				(*go)[ind_i] = VertexProperties(ind_i, weight_vertex.at(ind), NORMAL_PIXEL);
-			else
-				(*go)[ind_i] = VertexProperties(ind_i, weight_vertex.at(ind), TOP_PIXEL);
-		}
-	}
-
-	if(rec == false){
-		std::ifstream fichier (edge_weight, std::ios::in);
-
-		if(fichier){
-			bool found;
-			edge_to e1;
-			int edge1, edge2;
-			double edge_weight;
-			int lines = std::count(std::istreambuf_iterator<char>( fichier ),std::istreambuf_iterator<char>(),'\n' );
-			//std::cout<<lines<<std::endl;
-			int cpt =0;
-			int length;
-			fichier.seekg(0, std::ios::beg);
-			while(cpt < lines){
-			fichier >> edge1 >> edge2 >> edge_weight;
-			tie(e1,found)=edge(vertex(edge1,*go),vertex(edge2,*go),*go);
-			(*go)[e1] = EdgeProperties(edge_weight);
-			//std::cout<<edge1<<" "<<edge2<<" "<<edge_weight<<std::endl;
-			length = fichier.tellg();
-			fichier.seekg(length+1, std::ios::beg);
-			cpt++;
-			}
-
-		}else{
-			// std::cerr<<"Bugggggg du fichier txt !!!! "<<std::endl;
-		}
-		fichier.close();
-	}
-
-}
-
-void build_example_ligne(OrientedGraph& og)
-{
-	vertex_to v0 = boost::add_vertex(og);
-	vertex_to v1 = boost::add_vertex(og);
-	vertex_to v2 = boost::add_vertex(og);
-	vertex_to v3 = boost::add_vertex(og);
-	vertex_to v4 = boost::add_vertex(og);
-	vertex_to v5 = boost::add_vertex(og);
-	vertex_to v6 = boost::add_vertex(og);
-	vertex_to v7 = boost::add_vertex(og);
-
-	add_edge(v0, v1, EdgeProperties(1.), og);
-	add_edge(v1, v2, EdgeProperties(1.), og);
-	add_edge(v2, v3, EdgeProperties(1.), og);
-	add_edge(v3, v4, EdgeProperties(1.), og);
-	add_edge(v4, v5, EdgeProperties(1.), og);
-	add_edge(v5, v6, EdgeProperties(1.), og);
-	add_edge(v6, v7, EdgeProperties(1.), og);
-
-	og[v6] = VertexProperties(6, 1, NORMAL_PIXEL);
-	og[v0] = VertexProperties(0, 1, TOP_PIXEL);
-	og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
-	og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
-	og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
-	og[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
-	og[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
-	og[v7] = VertexProperties(7, 1, NORMAL_PIXEL);
-}
-
-void build_example_grid(OrientedGraph& og)
-{
-	vertex_to v0 = boost::add_vertex(og);
-	vertex_to v1 = boost::add_vertex(og);
-	vertex_to v2 = boost::add_vertex(og);
-	vertex_to v3 = boost::add_vertex(og);
-	vertex_to v4 = boost::add_vertex(og);
-	vertex_to v5 = boost::add_vertex(og);
-	vertex_to v6 = boost::add_vertex(og);
-	vertex_to v7 = boost::add_vertex(og);
-
-	add_edge(v0, v1, EdgeProperties(0.9), og);
-	add_edge(v0, v2, EdgeProperties(0.9), og);
-	add_edge(v0, v3, EdgeProperties(0.1), og);
-	add_edge(v1, v2, EdgeProperties(0.1), og);
-	add_edge(v1, v3, EdgeProperties(0.9), og);
-	add_edge(v2, v3, EdgeProperties(0.9), og);
-	add_edge(v2, v4, EdgeProperties(0.9), og);
-	add_edge(v2, v5, EdgeProperties(0.1), og);
-	add_edge(v3, v4, EdgeProperties(0.1), og);
-	add_edge(v3, v5, EdgeProperties(0.9), og);
-	add_edge(v4, v5, EdgeProperties(0.9), og);
-	add_edge(v4, v6, EdgeProperties(0.9), og);
-	add_edge(v4, v7, EdgeProperties(0.1), og);
-	add_edge(v5, v6, EdgeProperties(0.1), og);
-	add_edge(v5, v7, EdgeProperties(0.9), og);
-	add_edge(v6, v7, EdgeProperties(0.9), og);
-
-	og[v6] = VertexProperties(6, 1, NORMAL_PIXEL);
-	og[v0] = VertexProperties(0, 1, TOP_PIXEL);
-	og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
-	og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
-	og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
-	og[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
-	og[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
-	og[v7] = VertexProperties(7, 1, NORMAL_PIXEL);
-}
-
-void build_parcellaire_graph(OrientedGraph *go, uint size_max, std::string name)
-{
-	std::vector<std::pair<double,double> > point;
-	OrientedGraph::in_edge_iterator ei, edge_end;
-	double max_distance =  3000;//sqrt(2)*5*size_max/50;
-	double crit = sqrt(2)*5*size_max/1000;
-
-	std::cout << "distance max : " << max_distance << std::endl;
-	std::cout << "crit : " << crit << std::endl;
-	for(uint i = 0; i < size_max; i++)
-	{
-		std::pair<double,double> p;
-		p.first = rand()%(size_max*5-0) + 0;
-		p.second = rand()%(size_max*5-0) + 0;
-		point.push_back(p);
-	}
-
-	//std::cout << std::endl;
-	sort(point.begin(),point.end());
-	std::vector<std::vector<std::pair<double,uint> > > save_point_distance;
-
-	for(uint id = 0 ; id < point.size() - 1; id++)
-	{
-		std::vector<std::pair<double,uint> > point_distance, point_distance_sort;
-		//if(name != "multi"){
-			for(uint i = id +1 ; i < point.size(); i++)
-			{
-				std::pair<double,uint> pd;
-				pd.first = distance_t(point.at(id),point.at(i));
-				pd.second = i;
-				point_distance.push_back(pd);
-			}
-		/*}else{
-			for(uint i = 0 ; i < point.size(); i++)
-			{
-				std::pair<double,uint> pd;
-				pd.first = distance_t(point.at(id),point.at(i));
-				pd.second = i;
-				point_distance.push_back(pd);
-			}
-		}*/
-
-		point_distance_sort = point_distance;
-
-		sort(point_distance_sort.begin(), point_distance_sort.end());
-		std::vector<uint> deleted;
-		uint t;
-
-
-
-		if(point_distance_sort.size() > 50)
-			t = point_distance_sort.size()/2;
-		else
-			t = point_distance_sort.size();
-
-		/*if(name != "multi"){*/
-			for(uint i = 0 ; i < t; i++)
-			{
-				if(point_distance_sort.at(i).first < crit)
-					deleted.push_back(point_distance_sort.at(i).second);
-				//std::cout << point_distance_sort.at(i).second << " " << point_distance_sort.at(i).first <<std::endl;
-			}
-		/*}else{
-			for(uint i = 0 ; i < t; i++)
-			{
-				if(point_distance_sort.at(i).first < crit & point_distance_sort.at(i).first != 0)
-					deleted.push_back(point_distance_sort.at(i).second);
-				//std::cout << point_distance_sort.at(i).second << " " << point_distance_sort.at(i).first <<std::endl;
-			}
-		}*/
-		//std::cout<<std::endl;
-
-		sort(deleted.begin(), deleted.end());
-		std::reverse(deleted.begin(), deleted.end());
-
-		/*for(uint k = 0 ; k < deleted.size(); k++)
-			std::cout << deleted.at(k) << " " ;
-		std::cout<< std::endl << std::endl;*/
-
-		/*std::cout << "A : " << std::endl;
-		for(uint pp = 0; pp < point_distance.size(); pp++)
-			std::cout << point_distance.at(pp).second << " ";
-
-		std::cout<< std::endl << std::endl;*/
-
-		if(deleted.size() > 1)
-		{
-			//std::cout<<"Deleted"<<std::endl;
-			for(uint del = 0 ; del < deleted.size(); del++)
-			{
-				//std::cout << deleted.at(del) << " ";
-				for(uint idp = 0; idp < point_distance.size(); idp++)
-				{
-					if(point_distance.at(idp).second == deleted.at(del))
-					{
-						//std::cout << idp + id + 1 << std::endl;
-						/*if(name != "multi")
-						{*/
-							point.erase(point.begin() + idp + id + 1);
-							point_distance.erase(point_distance.begin() + idp);
-							for(uint pp = 0; pp < id ; pp++)
-							{
-								save_point_distance.at(pp).erase(save_point_distance.at(pp).begin() + idp);
-								for(uint j = idp; j < save_point_distance.at(pp).size(); j++)
-									save_point_distance.at(pp).at(j).second -=1;
-
-							}
-							for(uint j = idp; j < point_distance.size(); j++)
-								point_distance.at(j).second -= 1;
-						/*}else
-						{
-							point.erase(point.begin() + idp);
-							point_distance.erase(point_distance.begin() + idp);
-							for(uint pp = 0; pp < id ; pp++)
-							{
-								save_point_distance.at(pp).erase(save_point_distance.at(pp).begin() + idp);
-								for(uint j = idp; j < save_point_distance.at(pp).size(); j++)
-									save_point_distance.at(pp).at(j).second -=1;
-
-							}
-							for(uint j = idp; j < point_distance.size(); j++)
-								point_distance.at(j).second -= 1;
-						}*/
-						break;
-					}
-				}
-			}
-			//std::cout << std::endl;
-		}else if(deleted.size() == 1)
-		{
-			//std::cout<<"Deleted 2"<<std::endl;
-			//std::cout << deleted.at(0) << " ";
-			for(uint idp = 0; idp < point_distance.size(); idp++)
-			{
-
-				if(point_distance.at(idp).second == deleted.at(0))
-				{
-					/*if(name != "multi")
-					{*/
-						//std::cout << idp + id + 1 << std::endl;
-						point.erase(point.begin() + idp + id + 1);
-						point_distance.erase(point_distance.begin() + idp);
-						for(uint pp = 0; pp < id ; pp++)
-							{
-								save_point_distance.at(pp).erase(save_point_distance.at(pp).begin() + idp);
-								for(uint j = idp; j < save_point_distance.at(pp).size(); j++)
-									save_point_distance.at(pp).at(j).second -=1;
-
-							}
-						for(uint j = idp; j < point_distance.size(); j++)
-							point_distance.at(j).second -= 1;
-						//std::cout << " toto " << std::endl;
-
-					/*}else{
-						point.erase(point.begin() + idp);
-						point_distance.erase(point_distance.begin() + idp);
-						for(uint pp = 0; pp < id  ; pp++)
-						{
-							save_point_distance.at(pp).erase(save_point_distance.at(pp).begin() + idp);
-							for(uint j = idp; j < save_point_distance.at(pp).size(); j++)
-								save_point_distance.at(pp).at(j).second -=1;
-						}
-						for(uint j = idp; j < point_distance.size(); j++)
-							point_distance.at(j).second -= 1;
-					}*/
-					break;
-				}
-			}
-			//std::cout << std::endl;
-		}
-		/*std::cout << " B : " << std::endl;
-		for(uint pp = 0; pp < point_distance.size(); pp++)
-			std::cout << point_distance.at(pp).second << " ";
-
-		std::cout << std::endl << std::endl;*/
-
-		//sort(point_distance.begin(), point_distance.end());
-		save_point_distance.push_back(point_distance);
-		//std::cout << std::endl;
-	}
-	std::cout << "nombre de sommet" << point.size() << std::endl;
-
-
-	for(uint xt = 0; xt < save_point_distance.size(); xt++){
-		//std::cout << "** " << xt << " ** : ";
-		sort(save_point_distance.at(xt).begin(), save_point_distance.at(xt).end());
-		/*for(uint yt = 0; yt < save_point_distance.at(xt).size(); yt++){
-			std::cout << save_point_distance.at(xt).at(yt).first << " ";
-		}
-		std::cout << std::endl;*/
-	}
-
-
-	std::vector<vertex_to> Vertexs;
-	for(int i = 0; i < point.size(); i++){
-		vertex_to vo = boost::add_vertex(*go);
-		Vertexs.push_back(vo);
-	}
-
-	//std::cout << point.size() << std::endl;
-	for(int i = 0; i < point.size() -1; i++){
-		//std::cout << i << std::endl;
-		double dist = 0.;
-		uint xi;
-
-		//if(name != "multi")
-			xi = 0;
-		/*else
-			xi = 1;*/
-
-		while(dist < max_distance & xi < save_point_distance.at(i).size())
-		{
-			dist = save_point_distance.at(i).at(xi).first;
-			if(name != "multi")
-				add_edge(Vertexs.at(i), Vertexs.at(save_point_distance.at(i).at(xi).second), EdgeProperties(1.), *go);
-			else{
-				add_edge(Vertexs.at(i), Vertexs.at(save_point_distance.at(i).at(xi).second), EdgeProperties(1.), *go);
-				add_edge(Vertexs.at(save_point_distance.at(i).at(xi).second),Vertexs.at(i), EdgeProperties(1.), *go);
-			}
-			xi++;
-		}
-		(*go)[Vertexs.at(i)] = VertexProperties(i, 1., NORMAL_PIXEL);
-	}
-
-	(*go)[Vertexs.at(point.size()-1)] = VertexProperties(point.size()-1, 1., NORMAL_PIXEL);
-
-	/*std::cout << "ok"<< point.size() << std::endl;
-	for(int i = 0; i < (point.size() - arcs_max); i++)
-	{
-		std::cout << "ok"<< i << " "<< point.size() <<std::endl;
-		Entiers tmp_vector = Random_Sort_Vector2(i+1, point.size());
-		int ac = rand_fini(arcs_min, arcs_max);
-		std::cout << "! " << ac <<std::endl;
-		Entiers arcs;
-		for(uint p = 0; p < ac; p++)
-			arcs.push_back(tmp_vector.at(p));
-
-		//sort(arcs.begin(),arcs.end());
-
-		for(uint j = 0; j < arcs.size(); j++)
-			add_edge(Vertexs.at(i), Vertexs.at(arcs.at(j)), EdgeProperties(1.), *go);
-
-		(*go)[Vertexs.at(i)] = VertexProperties(i, 1., NORMAL_PIXEL);
-	}
-
-	std::cout << "ok1"<<std::endl;
-	for(int i = point.size() - arcs_max; i < point.size() - 2; i++)
-	{
-		Entiers tmp_vector = Random_Sort_Vector2(i+1,point.size());
-		int ac = rand_fini(1, 2);
-		Entiers arcs;
-		for(uint p = 0; p < ac; p++)
-			arcs.push_back(tmp_vector.at(p));
-
-		sort(arcs.begin(),arcs.end());
-
-		for(uint j = 0; j < arcs.size(); j++)
-			add_edge(Vertexs.at(i), Vertexs.at(arcs.at(j)), EdgeProperties(1.), *go);
-
-		(*go)[Vertexs.at(i)] = VertexProperties(i, 1., NORMAL_PIXEL);
-	}
-	std::cout << "ok2"<<std::endl;
-
-	add_edge(Vertexs.at(point.size()-2), Vertexs.at(point.size()-1), EdgeProperties(1.), *go);
-	(*go)[Vertexs.at(point.size()-2)] = VertexProperties(point.size()-2, 1., NORMAL_PIXEL);
-	(*go)[Vertexs.at(point.size()-1)] = VertexProperties(point.size()-1, 1., NORMAL_PIXEL);*/
-
-	for(uint i = 0; i< point.size(); i++){
-		bool indic = false;
-		for(tie(ei,edge_end) = in_edges(i,*go); ei != edge_end; ++ei){
-			indic = true;
-			break;
-		}
-		if(indic == false){
-			(*go)[i] = VertexProperties(i, 1, TOP_PIXEL);
-		}else{
-			(*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
-		}
-		//std::cout<<(*go)[i]._index<<" "<<indic<<" -> "<<(*go)[i]._type<<std::endl;
-	}
-
-
-}
-
-/*void build_graph_grid_center(OrientedGraph *go, int side, const std::vector<std::pair<int,int>> &vertex_selection, const Entiers &weight_vertex,const char *edge_weight, bool rec){
-	int nbr_vertex = side*side;
-	std::vector<vertex_to> Vertexs;
-	for(int i =0; i<nbr_vertex; i++){
-		vertex_to vo = boost::add_vertex(*go);
-		Vertexs.push_back(vo);
-	}
-
-	// Ité 0
-	for(uint i = 0; i < 4; i++){
-		boost::add_edge(0, 2 + 2*i ,EdgeProperties(1) , *go);
-	}
-
-	// Ité 1
-
-	for(uint i = 1; i < 9; i++){
-
-	}
-
-
-
-}*/
-
-/*Vérification de la pondération + vérification des poids de la contraction + vérification de la structure de contraction*/
-
-} } } // namespace paradevs tests boost_graph

+ 1432 - 0
src/tests/boost_graph/partitioning/graph_build.hpp

@@ -61,6 +61,1438 @@ void build_example_grid(OrientedGraph& og);
 
 void build_parcellaire_graph(OrientedGraph *go, uint size_max, std::string name);
 
+void build_graph(OrientedGraph& og, unsigned int edge_number)
+{
+
+    if(edge_number == 11){
+        vertex_to v0 = boost::add_vertex(og);
+        vertex_to v1 = boost::add_vertex(og);
+        vertex_to v2 = boost::add_vertex(og);
+        vertex_to v3 = boost::add_vertex(og);
+        vertex_to v4 = boost::add_vertex(og);
+        vertex_to v5 = boost::add_vertex(og);
+        vertex_to v6 = boost::add_vertex(og);
+        vertex_to v7 = boost::add_vertex(og);
+        vertex_to v8 = boost::add_vertex(og);
+        vertex_to v9 = boost::add_vertex(og);
+        vertex_to v10 = boost::add_vertex(og);
+
+        add_edge(v1, v0, EdgeProperties(1), og);
+        add_edge(v2, v0, EdgeProperties(1), og);
+        add_edge(v3, v0, EdgeProperties(1), og);
+        add_edge(v1, v2, EdgeProperties(1), og);
+        add_edge(v4, v1, EdgeProperties(1.), og);
+        add_edge(v5, v1, EdgeProperties(1.), og);
+        add_edge(v6, v1, EdgeProperties(1.), og);
+        add_edge(v6, v2, EdgeProperties(1.), og);
+        add_edge(v2, v3, EdgeProperties(1.), og);
+        add_edge(v9, v3, EdgeProperties(1.), og);
+        add_edge(v10, v3, EdgeProperties(1.), og);
+        add_edge(v4, v5, EdgeProperties(1), og);
+        add_edge(v5, v6, EdgeProperties(1), og);
+        add_edge(v7, v4, EdgeProperties(1.), og);
+        add_edge(v8, v4, EdgeProperties(1.), og);
+        add_edge(v7, v8, EdgeProperties(1), og);
+        add_edge(v9, v10, EdgeProperties(1.), og);
+
+        og[v6] = VertexProperties(6, 1, NORMAL_PIXEL);
+        og[v8] = VertexProperties(8, 1., NORMAL_PIXEL);
+        og[v10] = VertexProperties(10, 1, NORMAL_PIXEL);
+        og[v0] = VertexProperties(0, 1, NORMAL_PIXEL);
+        og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
+        og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
+        og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
+        og[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
+        og[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
+        og[v7] = VertexProperties(7, 1., TOP_PIXEL);
+        og[v9] = VertexProperties(9, 1., TOP_PIXEL);
+
+    } else if(edge_number == 38){
+
+        vertex_to v0 = boost::add_vertex(og);
+        vertex_to v1 = boost::add_vertex(og);
+        vertex_to v2 = boost::add_vertex(og);
+        vertex_to v3 = boost::add_vertex(og);
+        vertex_to v4 = boost::add_vertex(og);
+        vertex_to v5 = boost::add_vertex(og);
+        vertex_to v6 = boost::add_vertex(og);
+        vertex_to v7 = boost::add_vertex(og);
+        vertex_to v8 = boost::add_vertex(og);
+        vertex_to v9 = boost::add_vertex(og);
+        vertex_to v10 = boost::add_vertex(og);
+        vertex_to v11 = boost::add_vertex(og);
+        vertex_to v12 = boost::add_vertex(og);
+        vertex_to v13 = boost::add_vertex(og);
+        vertex_to v14 = boost::add_vertex(og);
+        vertex_to v15 = boost::add_vertex(og);
+        vertex_to v16 = boost::add_vertex(og);
+        vertex_to v17 = boost::add_vertex(og);
+        vertex_to v18 = boost::add_vertex(og);
+        vertex_to v19 = boost::add_vertex(og);
+        vertex_to v20 = boost::add_vertex(og);
+        vertex_to v21 = boost::add_vertex(og);
+        vertex_to v22 = boost::add_vertex(og);
+        vertex_to v23 = boost::add_vertex(og);
+        vertex_to v24 = boost::add_vertex(og);
+        vertex_to v25 = boost::add_vertex(og);
+        vertex_to v26 = boost::add_vertex(og);
+        vertex_to v27 = boost::add_vertex(og);
+        vertex_to v28 = boost::add_vertex(og);
+        vertex_to v29 = boost::add_vertex(og);
+        vertex_to v30 = boost::add_vertex(og);
+        vertex_to v31 = boost::add_vertex(og);
+        vertex_to v32 = boost::add_vertex(og);
+        vertex_to v33 = boost::add_vertex(og);
+        vertex_to v34 = boost::add_vertex(og);
+        vertex_to v35 = boost::add_vertex(og);
+        vertex_to v36 = boost::add_vertex(og);
+        vertex_to v37 = boost::add_vertex(og);
+
+        add_edge(v1, v0, EdgeProperties(1.), og);
+        add_edge(v2, v0, EdgeProperties(1.), og);
+        add_edge(v3, v0, EdgeProperties(1.), og);
+        add_edge(v1, v2, EdgeProperties(1.), og);
+        add_edge(v4, v1, EdgeProperties(1.), og);
+        add_edge(v5, v1, EdgeProperties(1.), og);
+        add_edge(v6, v1, EdgeProperties(1.), og);
+        add_edge(v6, v2, EdgeProperties(1.), og);
+        add_edge(v2, v3, EdgeProperties(1.), og);
+        add_edge(v9, v3, EdgeProperties(1.), og);
+        add_edge(v10, v3, EdgeProperties(1.), og);
+        add_edge(v4, v5, EdgeProperties(1.), og);
+        add_edge(v5, v6, EdgeProperties(1.), og);
+        add_edge(v7, v4, EdgeProperties(1.), og);
+        add_edge(v8, v4, EdgeProperties(1.), og);
+        add_edge(v7, v8, EdgeProperties(1.), og);
+        add_edge(v9, v10, EdgeProperties(1.), og);
+        add_edge(v8, v11, EdgeProperties(1.), og);
+        add_edge(v11, v4, EdgeProperties(1.), og);
+        add_edge(v12, v13, EdgeProperties(1.), og);
+        add_edge(v12, v7, EdgeProperties(1.), og);
+        add_edge(v13, v7, EdgeProperties(1.), og);
+        add_edge(v14, v15, EdgeProperties(1.), og);
+        add_edge(v14, v12, EdgeProperties(1.), og);
+        add_edge(v15, v16, EdgeProperties(1.), og);
+        add_edge(v15, v12, EdgeProperties(1.), og);
+        add_edge(v16, v17, EdgeProperties(1.), og);
+        add_edge(v16, v12, EdgeProperties(1.), og);
+        add_edge(v17, v12, EdgeProperties(1.), og);
+        add_edge(v18, v19, EdgeProperties(1.), og);
+        add_edge(v18, v8, EdgeProperties(1.), og);
+        add_edge(v19, v20, EdgeProperties(1.), og);
+        add_edge(v19, v8, EdgeProperties(1.), og);
+        add_edge(v20, v8, EdgeProperties(1.), og);
+        add_edge(v21, v22, EdgeProperties(1.), og);
+        add_edge(v21, v19, EdgeProperties(1.), og);
+        add_edge(v22, v23, EdgeProperties(1.), og);
+        add_edge(v22, v19, EdgeProperties(1.), og);
+        add_edge(v23, v19, EdgeProperties(1.), og);
+        add_edge(v24, v25, EdgeProperties(1.), og);
+        add_edge(v24, v6, EdgeProperties(1.), og);
+        add_edge(v25, v6, EdgeProperties(1.), og);
+        add_edge(v26, v11, EdgeProperties(1.), og);
+        add_edge(v26, v27, EdgeProperties(1.), og);
+        add_edge(v26, v24, EdgeProperties(1.), og);
+        add_edge(v27, v24, EdgeProperties(1.), og);
+        add_edge(v28, v25, EdgeProperties(1.), og);
+        add_edge(v29, v27, EdgeProperties(1.), og);
+        add_edge(v29, v28, EdgeProperties(1.), og);
+        add_edge(v30, v27, EdgeProperties(1.), og);
+        add_edge(v30, v28, EdgeProperties(1.), og);
+        add_edge(v31, v32, EdgeProperties(1.), og);
+        add_edge(v31, v10, EdgeProperties(1.), og);
+        add_edge(v32, v33, EdgeProperties(1.), og);
+        add_edge(v32, v10, EdgeProperties(1.), og);
+        add_edge(v33, v10, EdgeProperties(1.), og);
+        add_edge(v34, v31, EdgeProperties(1.), og);
+        add_edge(v34, v35, EdgeProperties(1.), og);
+        add_edge(v35, v31, EdgeProperties(1.), og);
+        add_edge(v35, v32, EdgeProperties(1.), og);
+        add_edge(v36, v32, EdgeProperties(1.), og);
+        add_edge(v36, v37, EdgeProperties(1.), og);
+        add_edge(v36, v33, EdgeProperties(1.), og);
+        add_edge(v37, v33, EdgeProperties(1.), og);
+
+        add_edge(v4, v0, EdgeProperties(1.), og);
+        add_edge(v9, v2, EdgeProperties(1.), og);
+        add_edge(v28, v24, EdgeProperties(1.), og);
+        add_edge(v28, v31, EdgeProperties(1.), og);
+        add_edge(v33, v3, EdgeProperties(1.), og);
+        add_edge(v33, v0, EdgeProperties(1.), og);
+        add_edge(v36, v3, EdgeProperties(1.), og);
+        add_edge(v17, v13, EdgeProperties(1.), og);
+        add_edge(v17, v7, EdgeProperties(1.), og);
+        add_edge(v21, v23, EdgeProperties(1.), og);
+        add_edge(v23, v20, EdgeProperties(1.), og);
+        add_edge(v26, v4, EdgeProperties(1.), og);
+
+        og[v6] = VertexProperties(6, 1, NORMAL_PIXEL);
+        og[v8] = VertexProperties(8, 1, NORMAL_PIXEL);
+        og[v10] = VertexProperties(10, 1, NORMAL_PIXEL);
+        og[v0] = VertexProperties(0, 1, NORMAL_PIXEL);
+        og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
+        og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
+        og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
+        og[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
+        og[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
+        og[v7] = VertexProperties(7, 1, NORMAL_PIXEL);
+        og[v9] = VertexProperties(9, 1, TOP_PIXEL);
+        og[v11] = VertexProperties(11, 1, NORMAL_PIXEL);
+        og[v12] = VertexProperties(12, 1, NORMAL_PIXEL);
+        og[v13] = VertexProperties(13, 1, NORMAL_PIXEL);
+        og[v14] = VertexProperties(14, 1, TOP_PIXEL);
+        og[v15] = VertexProperties(15, 1, NORMAL_PIXEL);
+        og[v16] = VertexProperties(16, 1, NORMAL_PIXEL);
+        og[v17] = VertexProperties(17, 1, NORMAL_PIXEL);
+        og[v18] = VertexProperties(18, 1, TOP_PIXEL);
+        og[v19] = VertexProperties(19, 1, NORMAL_PIXEL);
+        og[v20] = VertexProperties(20, 1, NORMAL_PIXEL);
+        og[v21] = VertexProperties(21, 1, TOP_PIXEL);
+        og[v22] = VertexProperties(22, 1, NORMAL_PIXEL);
+        og[v23] = VertexProperties(23, 1, NORMAL_PIXEL);
+        og[v24] = VertexProperties(24, 1, NORMAL_PIXEL);
+        og[v25] = VertexProperties(25, 1, NORMAL_PIXEL);
+        og[v26] = VertexProperties(26, 1, TOP_PIXEL);
+        og[v27] = VertexProperties(27, 1, NORMAL_PIXEL);
+        og[v28] = VertexProperties(28, 1, NORMAL_PIXEL);
+        og[v29] = VertexProperties(29, 1, TOP_PIXEL);
+        og[v30] = VertexProperties(30, 1, TOP_PIXEL);
+        og[v31] = VertexProperties(31, 1, NORMAL_PIXEL);
+        og[v32] = VertexProperties(32, 1, NORMAL_PIXEL);
+        og[v33] = VertexProperties(33, 1, NORMAL_PIXEL);
+        og[v34] = VertexProperties(34, 1, TOP_PIXEL);
+        og[v35] = VertexProperties(35, 1, NORMAL_PIXEL);
+        og[v36] = VertexProperties(36, 1, TOP_PIXEL);
+        og[v37] = VertexProperties(37, 1, NORMAL_PIXEL);
+
+    }else{
+        // std::cout<<"Le type de artificiel graphe choisi n'existe pas ! "<<std::endl;
+    }
+}
+
+void modify_file_paths(std::string& absolutePath,
+                       std::vector < std::string* >& files)
+{
+    for (std::vector < std::string* >::iterator it = files.begin();
+         it != files.end(); it++) {
+        (*it)->insert(0, absolutePath);
+    }
+}
+
+void build_graph_cyclique(OrientedGraph& og)
+{
+    vertex_to v0 = boost::add_vertex(og);
+    vertex_to v1 = boost::add_vertex(og);
+    vertex_to v2 = boost::add_vertex(og);
+    vertex_to v3 = boost::add_vertex(og);
+    vertex_to v4 = boost::add_vertex(og);
+    vertex_to v5 = boost::add_vertex(og);
+    vertex_to v6 = boost::add_vertex(og);
+    vertex_to v7 = boost::add_vertex(og);
+    vertex_to v8 = boost::add_vertex(og);
+    vertex_to v9 = boost::add_vertex(og);
+    vertex_to v10 = boost::add_vertex(og);
+
+    add_edge(v0, v1, EdgeProperties(1.), og);
+    add_edge(v0, v2, EdgeProperties(1.), og);
+    add_edge(v0, v3, EdgeProperties(1.), og);
+    add_edge(v1, v3, EdgeProperties(1.), og);
+    add_edge(v2, v1, EdgeProperties(1.), og);
+    add_edge(v2, v3, EdgeProperties(1.), og);
+    add_edge(v2, v4, EdgeProperties(1.), og);
+    add_edge(v2, v5, EdgeProperties(1.), og);
+    add_edge(v2, v7, EdgeProperties(1.), og);
+    add_edge(v2, v9, EdgeProperties(1.), og);
+    add_edge(v3, v4, EdgeProperties(1.), og);
+    add_edge(v3, v5, EdgeProperties(1.), og);
+    add_edge(v3, v7, EdgeProperties(1.), og);
+    add_edge(v3, v9, EdgeProperties(1.), og);
+    add_edge(v4, v6, EdgeProperties(1.), og);
+    add_edge(v5, v4, EdgeProperties(1.), og);
+    add_edge(v5, v6, EdgeProperties(1.), og);
+    add_edge(v6, v7, EdgeProperties(1.), og);
+    add_edge(v7, v8, EdgeProperties(1.), og);
+    add_edge(v7, v10, EdgeProperties(1.), og);
+    add_edge(v8, v9, EdgeProperties(1.), og);
+    add_edge(v8, v10, EdgeProperties(1.), og);
+    add_edge(v9, v10, EdgeProperties(1.), og);
+    add_edge(v10, v0, EdgeProperties(1.), og);
+
+    og[v6] = VertexProperties(6, 1, NORMAL_PIXEL);
+    og[v8] = VertexProperties(8, 1, NORMAL_PIXEL);
+    og[v10] = VertexProperties(10, 1, NORMAL_PIXEL);
+    og[v0] = VertexProperties(0, 1, NORMAL_PIXEL);
+    og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
+    og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
+    og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
+    og[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
+    og[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
+    og[v7] = VertexProperties(7, 1, NORMAL_PIXEL);
+    og[v9] = VertexProperties(9, 1, NORMAL_PIXEL);
+}
+
+void build_example_linked9(OrientedGraph& og)
+{
+    vertex_to v0 = boost::add_vertex(og);
+    vertex_to v1 = boost::add_vertex(og);
+    vertex_to v2 = boost::add_vertex(og);
+    vertex_to v3 = boost::add_vertex(og);
+    vertex_to v4 = boost::add_vertex(og);
+    vertex_to v5 = boost::add_vertex(og);
+    vertex_to v6 = boost::add_vertex(og);
+    vertex_to v7 = boost::add_vertex(og);
+    vertex_to v8 = boost::add_vertex(og);
+    vertex_to v9 = boost::add_vertex(og);
+
+    add_edge(v1, v0, EdgeProperties(1.), og);
+    add_edge(v2, v0, EdgeProperties(1.), og);
+    add_edge(v3, v0, EdgeProperties(1.), og);
+    add_edge(v4, v1, EdgeProperties(1.), og);
+    add_edge(v4, v2, EdgeProperties(1.), og);
+    add_edge(v5, v1, EdgeProperties(1.), og);
+    add_edge(v6, v1, EdgeProperties(1.), og);
+    add_edge(v6, v2, EdgeProperties(1.), og);
+    add_edge(v6, v3, EdgeProperties(1.), og);
+    add_edge(v7, v2, EdgeProperties(1.), og);
+    add_edge(v7, v3, EdgeProperties(1.), og);
+    add_edge(v8, v2, EdgeProperties(1.), og);
+    add_edge(v9, v1, EdgeProperties(1.), og);
+    add_edge(v9, v3, EdgeProperties(1.), og);
+
+    og[v6] = VertexProperties(6, 1, TOP_PIXEL);
+    og[v8] = VertexProperties(8, 1, TOP_PIXEL);
+    og[v0] = VertexProperties(0, 1, NORMAL_PIXEL);
+    og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
+    og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
+    og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
+    og[v4] = VertexProperties(4, 1, TOP_PIXEL);
+    og[v5] = VertexProperties(5, 1, TOP_PIXEL);
+    og[v7] = VertexProperties(7, 1, TOP_PIXEL);
+    og[v9] = VertexProperties(9, 1, TOP_PIXEL);
+}
+
+/*void build_corsen_graph(OrientedGraph& graph)
+  {
+  std::string absolutePath(
+  "/home/eric/vle/vle-labs/paradevs/src/tests/corsen/data_s/");
+  std::string modeFile(".mode");
+  std::string parametersFile("par.txt");
+  std::string elevationFile("alt");
+  std::string outletFile("arbre");
+  std::string layersFile("couche");
+  std::string contextFile("contexte_yar_scenario.xml");
+  std::string slopeFile("pav");
+  std::vector < std::string* > files;
+  Corsen c;
+
+  files.push_back(&parametersFile);
+  files.push_back(&modeFile);
+  files.push_back(&elevationFile);
+  files.push_back(&outletFile);
+  files.push_back(&slopeFile);
+  files.push_back(&contextFile);
+  files.push_back(&layersFile);
+  modify_file_paths(absolutePath, files);
+
+  c.read(files, absolutePath);
+  c.buildGraph();
+
+  const DirectedGraph& g = c.getGraph().graph();
+  std::vector < vertex_t > og_vertex_list;
+  std::vector < vertex_t > dg_vertex_list;
+  std::vector < int > dg_in_vertex_list;
+  DirectedGraph::vertex_iterator it_dg, end_dg;
+
+  tie(it_dg, end_dg) = vertices(g);
+  for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
+  og_vertex_list.push_back(add_vertex(graph));
+  dg_vertex_list.push_back(*it_dg);
+  dg_in_vertex_list.push_back(0);
+  }
+
+  tie(it_dg, end_dg) = vertices(g);
+  for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
+  DirectedGraph::adjacency_iterator neighbour_it, neighbour_end;
+
+  tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_dg, g);
+  for (; neighbour_it != neighbour_end; ++neighbour_it) {
+  uint index = 0;
+
+  while (dg_vertex_list[index] != *neighbour_it) {
+  ++index;
+  }
+  ++dg_in_vertex_list[index];
+  boost::add_edge(og_vertex_list[i], og_vertex_list[index],
+  EdgeProperties(1.), graph);
+  }
+  }
+
+  tie(it_dg, end_dg) = vertices(g);
+  for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
+  if (dg_in_vertex_list[i] == 0) {
+  graph[og_vertex_list[i]] = VertexProperties(i, 1., TOP_PIXEL);
+  } else {
+  graph[og_vertex_list[i]] = VertexProperties(i, 1., NORMAL_PIXEL);
+  }
+  }
+  }*/
+
+
+void brhtg_source(OrientedGraph *go,int nbr_vertex, int nbr_source,
+                  int nbr_v_min, int nbr_v_max, const std::vector<int> &niveau,
+                  std::vector<int> &Ram, std::vector<int> &Exu,
+                  const std::vector<vertex_to> &Vertexs,
+                  int nbr_passe, int nbr_npb)
+{
+    uint nbr_voisin;
+
+    int niv=1;
+    for(uint j =0; j<niveau.size()-1; j++){
+        niv *= niveau.at(j);
+    }
+
+    int niv_tot=1;
+    for(uint j =0; j<niveau.size(); j++){
+        niv_tot *= niveau.at(j);
+    }
+
+    for(int b = 0; b<niv; b++){
+        std::vector<uint> branche;
+        int cpt = 0;
+        while(cpt != niveau.at(niveau.size()-1)+1){
+            branche.push_back((b*niveau.at(niveau.size()-1)+cpt)*nbr_npb);
+            cpt++;
+        }
+
+        for(uint i =0; i<branche.size()-1;i++){
+            for(uint j = branche.at(i); j<branche.at(i+1); j++){
+                if(j==branche.at(branche.size()-1)-1){
+                    break;
+                }
+                else{
+                    nbr_voisin = rand_fini(nbr_v_min, nbr_v_max+1);
+                    uint cpt=0;
+                    Entiers ensemble;
+                    int cpt_nbr_s = 0;
+                    while(cpt != nbr_voisin){
+                        int val;
+                        if(j<branche.at(i)+nbr_source){ // Les sommets sont des sources donc imossible de recevoir des données
+                            val = rand_fini(j + 4, j + nbr_v_max + nbr_passe);
+                        }
+                        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
+                            val = rand_fini(branche.at(branche.size()-1)-4, branche.at(branche.size()-1));
+                        }
+                        else if(j>=branche.at(i)+nbr_npb-nbr_passe && i== (branche.size()-2)){ // Les sommets sont proche de l'exutoire
+                            val = rand_fini(j+1,branche.at(branche.size()-1));
+                        }
+                        else{ // Les sommets sont en plein milieu d'une branche
+                            val = rand_fini(j+1, j+nbr_passe);
+                        }
+
+                        if(In_tab(ensemble,val) != 1){
+                            ensemble.push_back(val);
+                            boost::add_edge(Vertexs.at(j), Vertexs.at(val), EdgeProperties(1.), *go);
+                            cpt++;
+                        }
+                        else{
+                            if((nbr_vertex-j) == cpt)
+                                break;
+                            else
+                                cpt_nbr_s++;
+                        }
+
+                        if(cpt_nbr_s>2*nbr_passe)
+                            break;
+                    }
+
+                }
+            }
+        }
+
+        /*for(int i =0; i<branche.size()-1; i++){
+          for(int j = branche.at(i)+nbr_source; j<branche.at(i+1); j++){
+          (*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
+          }
+          }
+
+          for(int i =0; i<branche.size()-1; i++){
+          for(int j = branche.at(i); j<branche.at(i)+nbr_source; j++){
+          (*go)[Vertexs.at(j)] = VertexProperties(j, 1, TOP_PIXEL);
+          }
+          }*/
+
+        Ram.push_back((niv_tot+b)*nbr_npb);
+        Exu.push_back(branche.at(branche.size()-1)-1);
+    }
+
+    Ram.push_back(Ram.at(Ram.size()-1)+nbr_npb);
+
+    if(niveau.size()>1){
+        nbr_voisin = 2;
+        for(uint k =0; k<Exu.size(); k++){
+            for(uint l = Exu.at(k)-2; l<Exu.at(k)+1; l++){
+                int cpt=0;
+                Entiers ensemble;
+                int cpt_nbr_s = 0;
+                while(cpt!=nbr_voisin){
+                    int val = rand_fini(Ram.at(k),Ram.at(k)+2);
+
+                    if(In_tab(ensemble,val)!=1){
+                        ensemble.push_back(val);
+                        boost::add_edge(Vertexs.at(l), Vertexs.at(val), EdgeProperties(1.), *go);
+                        cpt++;
+                    }
+                    else{
+                        if((nbr_vertex-l)==cpt)
+                            break;
+                        else
+                            cpt_nbr_s++;
+                    }
+
+                    if(cpt_nbr_s>2*nbr_passe)
+                        break;
+                }
+            }
+        }
+    }
+}
+
+void brhtg_ramification(OrientedGraph *go, int nbr_vertex, int nbr_v_min,
+                        int nbr_v_max, const std::vector<int> &niveau,
+                        std::vector<int> &Ram, std::vector<int> &Exu,
+                        const std::vector<vertex_to> &Vertexs,
+                        int nbr_passe, int nbr_npb)
+{
+    int nbr_voisin;
+    int cpt_ram = 1;
+    while(cpt_ram != niveau.size()-1){
+        int niv=1;
+        for(int j =0; j<niveau.size()-1-cpt_ram; j++){
+            niv *= niveau.at(j);
+        }
+
+        int niv_tot=0;
+        for(int i =0; i<=cpt_ram; i++){
+            int tmp_niv_tot=1;
+            for(int j =0; j<niveau.size()-i; j++){
+                tmp_niv_tot *= niveau.at(j);
+            }
+            niv_tot+=tmp_niv_tot;
+        }
+
+        std::vector<std::vector<int> > branche;
+        int cpt_b=0;
+        for(int j = 0; j<(Ram.size()-1)/niveau.at(niveau.size()-1-cpt_ram); j++){
+            std::vector<int> tmp_branche;
+            for(int i =0; i< niveau.at(niveau.size()-1-cpt_ram); i++){
+                tmp_branche.push_back(Ram.at(i+cpt_b));
+            }
+            tmp_branche.push_back(tmp_branche.at(tmp_branche.size()-1)+nbr_npb);
+            branche.push_back(tmp_branche);
+            cpt_b+=niveau.at(niveau.size()-1-cpt_ram);
+        }
+
+        Ram.clear();
+        Exu.clear();
+
+        for(int b = 0; b<niv; b++){
+
+            for(int i =0; i<branche.at(b).size()-1;i++){
+                for(int j = branche.at(b).at(i); j<branche.at(b).at(i+1); j++){
+                    if(j==branche.at(b).at(branche.at(b).size()-1)-1){
+                        break;
+                    }
+                    else{
+                        nbr_voisin = rand_fini(nbr_v_min, nbr_v_max+1);
+                        int cpt=0;
+                        Entiers ensemble;
+                        int cpt_nbr_s = 0;
+                        while(cpt!=nbr_voisin){
+                            int val;
+
+                            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
+                                val = rand_fini(branche.at(b).at(branche.at(b).size()-1)-4, branche.at(b).at(branche.at(b).size()-1));
+                            }
+                            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
+                                val = rand_fini(j+1,branche.at(b).at(branche.at(b).size()-1));
+                            }
+                            else{ // Les sommets sont en plein milieu d'une branche
+                                val = rand_fini(j+1, j+nbr_passe);
+                            }
+
+                            if(In_tab(ensemble,val)!=1){
+                                ensemble.push_back(val);
+                                boost::add_edge(Vertexs.at(j), Vertexs.at(val), EdgeProperties(1.), *go);
+                                cpt++;
+                            }
+                            else{
+                                if((nbr_vertex-j)==cpt)
+                                    break;
+                                else
+                                    cpt_nbr_s++;
+                            }
+
+                            if(cpt_nbr_s>2*nbr_passe)
+                                break;
+                        }
+
+                    }
+                }
+            }
+            Ram.push_back((niv_tot+b)*nbr_npb);
+            Exu.push_back(branche.at(b).at(branche.at(b).size()-1)-1);
+
+            /*for(int y =0; y<branche.at(b).size()-1; y++){
+              for(int x = branche.at(b).at(y); x<branche.at(b).at(y+1); x++){
+              (*go)[Vertexs.at(x)] = VertexProperties(x, 1, NORMAL_PIXEL);
+              }
+              }*/
+        }
+
+        Ram.push_back(Ram.at(Ram.size()-1)+nbr_npb);
+
+        nbr_voisin = 2;
+        for(int k =0; k<Exu.size(); k++){
+            for(int l = Exu.at(k)-1; l<Exu.at(k)+1; l++){
+                int cpt=0;
+                Entiers ensemble;
+                int cpt_nbr_s = 0;
+                while(cpt!=nbr_voisin){
+                    int val = rand_fini(Ram.at(k),Ram.at(k)+2);
+
+                    if(In_tab(ensemble,val)!=1){
+                        ensemble.push_back(val);
+                        boost::add_edge(Vertexs.at(l), Vertexs.at(val), EdgeProperties(1.), *go);
+                        cpt++;
+                    }
+                    else{
+                        if((nbr_vertex-l)==cpt)
+                            break;
+                        else
+                            cpt_nbr_s++;
+                    }
+
+                    if(cpt_nbr_s>2*nbr_passe)
+                        break;
+                }
+            }
+        }
+        cpt_ram++;
+    }
+}
+
+void brhtg_exutoire(OrientedGraph *go,int nbr_vertex,int nbr_v_min,
+                    int nbr_v_max,
+                    std::vector<int> &Ram,
+                    const std::vector<vertex_to> &Vertexs,
+                    int nbr_passe)
+{
+    int nbr_voisin;
+    Ram.at(Ram.size()-1)=nbr_vertex;
+
+    for(int i =0; i<Ram.size()-1;i++){
+        for(int j = Ram.at(i); j<Ram.at(i+1); j++){
+            if(j==Ram.at(Ram.size()-1)-1){
+                //(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
+                break;
+            }
+            else{
+                if(Ram.at(i+1)-j<nbr_passe)
+                    nbr_voisin = 2;
+                else
+                    nbr_voisin = rand_fini(nbr_v_min, nbr_v_max+1);
+                int cpt=0;
+                Entiers ensemble;
+                int cpt_nbr_s = 0;
+                while(cpt!=nbr_voisin){
+                    int val;
+
+                    if(j>=Ram.at(i+1)-nbr_passe && i!=Ram.size()-2){ // Les sommets sont proche de l'exutoire
+                        val = rand_fini(Ram.at(Ram.size()-1)-4,Ram.at(Ram.size()-1));
+                    }
+                    else if(j>=Ram.at(i+1)-nbr_passe && i==Ram.size()-2){ // Les sommets sont proche de l'exutoire
+                        val = rand_fini(j+1,Ram.at(Ram.size()-1));
+                    }
+                    else{ // Les sommets sont en plein milieu d'une branche
+                        val = rand_fini(j+1, j+nbr_passe);
+                    }
+
+                    if(In_tab(ensemble,val)!=1&& j!=val){
+                        ensemble.push_back(val);
+                        boost::add_edge(Vertexs.at(j), Vertexs.at(val), EdgeProperties(1.), *go);
+                        cpt++;
+                    }
+                    else{
+                        if((nbr_vertex-j)==cpt)
+                            break;
+                        else
+                            cpt_nbr_s++;
+                    }
+
+                    if(cpt_nbr_s>2*nbr_passe)
+                        break;
+                }
+
+            }
+            //(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
+        }
+    }
+}
+
+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)
+{
+    std::vector<vertex_to> Vertexs;
+    OrientedGraph::in_edge_iterator ei, edge_end;
+
+    int nbr_npb;
+    int nbr_branche = 0;
+    int nbr_passe = 4;
+
+    for(int i =0; i<nbr_vertex; i++){
+        vertex_to vo = boost::add_vertex(*go);
+        Vertexs.push_back(vo);
+    }
+
+    // Calcul du nombre de branches à partir de l'information des niveaux
+    for(int i =0; i< niveau.size(); i++){
+        int nbr_tmp =1;
+        for(int j =0; j<=i; j++){
+            nbr_tmp *= niveau.at(j);
+        }
+        nbr_branche += nbr_tmp;
+    }
+    // std::cout<<nbr_branche<<std::endl;
+
+    nbr_npb = nbr_vertex/(nbr_branche);
+
+    std::vector<int> Ram;
+    std::vector<int> Exu;
+
+    if(niveau.size()>1){
+        /*
+         * *** Code Source ***
+         */
+
+        brhtg_source(go,nbr_vertex,nbr_source,nbr_v_min,nbr_v_max,niveau,Ram,Exu,Vertexs,nbr_passe,nbr_npb);
+
+        /*
+         * *** Code Ramifications ***
+         */
+
+        brhtg_ramification(go,nbr_vertex,nbr_v_min,nbr_v_max,niveau,
+                           Ram,Exu,Vertexs,nbr_passe,nbr_npb);
+
+        /*
+         * *** Code Exutoire ***
+         */
+
+        brhtg_exutoire(go,nbr_vertex,nbr_v_min,nbr_v_max,
+                       Ram,Vertexs,nbr_passe);
+
+    } else {
+        brhtg_source(go,nbr_vertex,nbr_source,nbr_v_min,nbr_v_max,niveau,Ram,Exu,Vertexs,nbr_passe,nbr_npb);
+    }
+
+    std::vector < int > dg_in_vertex_list;
+    std::vector <vertex_to> dg_vertex_list;
+    OrientedGraph::vertex_iterator it_dg, end_dg;
+
+    tie(it_dg, end_dg) = vertices(*go);
+    for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
+        dg_in_vertex_list.push_back(0);
+        dg_vertex_list.push_back(*it_dg);
+    }
+
+    tie(it_dg, end_dg) = vertices(*go);
+    for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
+        OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
+
+        tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_dg, *go);
+        for (; neighbour_it != neighbour_end; ++neighbour_it) {
+            uint index = 0;
+
+            while (dg_vertex_list[index] != *neighbour_it) {
+                ++index;
+            }
+            ++dg_in_vertex_list[index];
+        }
+    }
+
+    int compteur = 0;
+    for(uint i = 0; i<num_vertices(*go); i++){
+        bool indic = false;
+        for(tie(ei,edge_end) = in_edges(i,*go); ei != edge_end; ++ei){
+            indic = true;
+            break;
+        }
+        if(dg_in_vertex_list.at(i) == 0 || indic == false){
+            compteur++;
+            (*go)[i] = VertexProperties(i, 1, TOP_PIXEL);
+        }else{
+            (*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
+        }
+        //std::cout<<(*go)[i]._index<<" "<<indic<<" -> "<<(*go)[i]._type<<std::endl;
+    }
+
+    // std::cout<<"Compteur : "<<compteur<<std::endl;
+}
+
+void build_generator_graph_linked(OrientedGraph *go, int nbr_vertex,
+                                  int nbr_couche, int nbr_v_min, int nbr_v_max)
+{
+    std::vector<vertex_to> Vertexs;
+    OrientedGraph::in_edge_iterator ei, edge_end;
+
+    for(int i =0; i<nbr_vertex; i++){
+        vertex_to vo = boost::add_vertex(*go);
+        Vertexs.push_back(vo);
+    }
+
+    /*Création du vecteur contenant le nombre de sommets par couche*/
+    int midel_couche = nbr_couche-2;
+    int top_couche;
+    if(nbr_couche>5){
+        top_couche = floor(nbr_vertex/3);//floor(midel_couche/2));
+    }else{
+        top_couche = floor(nbr_vertex/2);
+    }
+    int nbr_vertex_midel_couche = nbr_vertex - top_couche -1;
+    int tmp = 0;
+    std::vector<int> nbr_som_couche;
+    nbr_som_couche.push_back(1);
+
+    for(int i = 1; i <= midel_couche; i++){
+        tmp += i;
+    }
+
+    for(int i = 0; i < midel_couche; i++){
+        nbr_som_couche.push_back(floor((i+1)*nbr_vertex_midel_couche/tmp));
+    }
+
+    nbr_som_couche.push_back(top_couche);
+
+    int sum = 0;
+    for(int i = 0; i < nbr_som_couche.size(); i++){
+        sum += nbr_som_couche.at(i);
+    }
+    int reste = nbr_vertex - sum;
+
+    /*std::cout<<"sum : "<<sum<<std::endl;
+      std::cout<<"midel_couche : "<<midel_couche<<std::endl;
+      std::cout<<"top_couche : "<<top_couche<<std::endl;
+      std::cout<<"nbr_vertex_midel_couche : "<<nbr_vertex_midel_couche<<std::endl;
+      std::cout<<"tmp : "<<tmp<<std::endl;
+      std::cout<<"reste : "<<reste<<std::endl;
+
+      for(int i =0; i < nbr_som_couche.size(); i++){
+      std::cout<<nbr_som_couche.at(i)<<" ";
+      }
+      std::cout<<std::endl;*/
+
+    while(reste != 0){
+        for(int i = 1; i <nbr_som_couche.size(); i++){
+            nbr_som_couche.at(i) += 1;
+            reste --;
+            if(reste == 0){
+                break;
+            }
+        }
+    }
+
+    /*for(int i =0; i < nbr_som_couche.size(); i++){
+      std::cout<<nbr_som_couche.at(i)<<" ";
+      }
+      std::cout<<std::endl;*/
+
+    /*Génération du graphe*/
+    std::vector<int> tab_couche_som;
+    tab_couche_som.push_back(0);
+
+    for(int i =1; i<nbr_som_couche.size(); i++){
+        tab_couche_som.push_back(tab_couche_som.at(i-1)+nbr_som_couche.at(i));
+    }
+
+    /*for(int i =0; i < tab_couche_som.size(); i++){
+      std::cout<<tab_couche_som.at(i)<<" ";
+      }
+      std::cout<<std::endl;*/
+    int nbr_vois = nbr_v_max+2;
+
+    int cpt = 0;
+    for(int i = tab_couche_som.at(tab_couche_som.size()-2)+1; i <= tab_couche_som.at(tab_couche_som.size()-1); i++){
+        std::vector<int> vertex_tmp;
+        int rand = rand_fini(nbr_v_min,nbr_v_max+1);
+        int neigh_cpt = 0;
+        while(neigh_cpt != rand){
+            int val;
+            if(cpt<nbr_vois){
+                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);
+                //std::cout<<"val1 : "<<val<<std::endl;
+            }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)){
+                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);
+                //std::cout<<"val2 : "<<val<<std::endl;
+            }else{
+                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);
+                //std::cout<<"val3 : "<<val<<std::endl;
+            }
+            if(In_tab(vertex_tmp,val) != 1){
+                boost::add_edge(Vertexs.at(i), Vertexs.at(val), EdgeProperties(1.), *go);
+                vertex_tmp.push_back(val);
+                neigh_cpt ++;
+            }
+        }
+        cpt ++;
+    }
+    //std::cout<<"Passage !"<<std::endl;
+
+    for(int j = 2; j < tab_couche_som.size()-1; j++){
+        cpt = 0;
+        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++){
+            std::vector<int> vertex_tmp;
+            int rand = rand_fini(nbr_v_min,nbr_v_max+1);
+            //std::cout<<"rand : "<<rand<<std::endl;
+            int neigh_cpt = 0;
+            while(neigh_cpt != rand){
+                int val;
+                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){
+                    if(cpt<nbr_vois){
+                        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);
+                        //std::cout<<"val1 : "<<val<<std::endl;
+                    }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)){
+                        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);
+                        //std::cout<<"val2 : "<<val<<std::endl;
+                    }else{
+                        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)){
+                            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);
+                        }else{
+                            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);
+                        }
+                        //std::cout<<"val3 : "<<val<<std::endl;
+                    }
+                }else{
+                    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);
+                }
+                //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);
+                if(In_tab(vertex_tmp,val) != 1){
+                    boost::add_edge(Vertexs.at(i), Vertexs.at(val), EdgeProperties(1.), *go);
+                    vertex_tmp.push_back(val);
+                    neigh_cpt ++;
+                }
+            }
+            cpt ++;
+        }
+    }
+    //std::cout<<"Passage2 !"<<std::endl;
+
+    for(int i = tab_couche_som.at(0)+1; i <= tab_couche_som.at(1); i++){
+        //int val = rand_fini(0,2);
+        //if(val == 0){
+        boost::add_edge(Vertexs.at(i), Vertexs.at(0), EdgeProperties(1.), *go);
+        //}
+    }
+    //std::cout<<"Passage3 !"<<std::endl;
+
+    std::vector < int > dg_in_vertex_list;
+    std::vector <vertex_to> dg_vertex_list;
+    OrientedGraph::vertex_iterator it_dg, end_dg;
+
+    tie(it_dg, end_dg) = vertices(*go);
+    for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
+        dg_in_vertex_list.push_back(0);
+        dg_vertex_list.push_back(*it_dg);
+    }
+
+    tie(it_dg, end_dg) = vertices(*go);
+    for (uint i = 0; it_dg != end_dg; ++it_dg, ++i) {
+        OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
+
+        tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_dg, *go);
+        for (; neighbour_it != neighbour_end; ++neighbour_it) {
+            uint index = 0;
+
+            while (dg_vertex_list[index] != *neighbour_it) {
+                ++index;
+            }
+            ++dg_in_vertex_list[index];
+        }
+    }
+
+    for(uint i = 0; i<num_vertices(*go); i++){
+        bool indic = false;
+        for(tie(ei,edge_end) = in_edges(i,*go); ei != edge_end; ++ei){
+            indic = true;
+            break;
+        }
+        if(dg_in_vertex_list.at(i) == 0 || indic == false){
+            (*go)[i] = VertexProperties(i, 1, TOP_PIXEL);
+        }else{
+            (*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
+        }
+    }
+}
+
+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)
+{
+    int nbr_vertex = side*side;
+    std::vector<vertex_to> Vertexs;
+    for(int i =0; i<nbr_vertex; i++){
+        vertex_to vo = boost::add_vertex(*go);
+        Vertexs.push_back(vo);
+    }
+
+    if(rec == true){
+        std::ofstream fichier (edge_weight, std::ios::out);
+        for(int i = 0; i<side; i++){
+            for(int j = 0; j<side-1; j++){
+                boost::add_edge(i*side+j, i*side+j+1,EdgeProperties(1), *go);
+                fichier<<i*side+j<<" "<<i*side+j+1<<" "<<1<<" "<<std::endl;
+            }
+        }
+
+        for(int i = 0; i<side-1; i++){
+            for(int j = 0; j<side; j++){
+                boost::add_edge(i*side+j, (i+1)*side+j,EdgeProperties(1), *go);
+                fichier<<i*side+j<<" "<<(i+1)*side+j<<" "<<1<<" "<<std::endl;
+            }
+        }
+        fichier.close();
+    }else{
+        for(int i = 0; i<side; i++){
+            for(int j = 0; j<side-1; j++){
+                boost::add_edge(i*side+j, i*side+j+1,EdgeProperties(1), *go);
+            }
+        }
+
+        for(int i = 0; i<side-1; i++){
+            for(int j = 0; j<side; j++){
+                boost::add_edge(i*side+j, (i+1)*side+j,EdgeProperties(1), *go);
+            }
+        }
+    }
+
+    (*go)[0] = VertexProperties(0, 1, TOP_PIXEL);
+    for(uint i = 1; i<num_vertices(*go); i++){
+        (*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
+    }
+
+    for(int ind=0; ind<vertex_selection.size(); ind++){
+        for(int ind_i = vertex_selection.at(ind).first; ind_i<vertex_selection.at(ind).second+1; ind_i++){
+            if(ind_i != 0)
+                (*go)[ind_i] = VertexProperties(ind_i, weight_vertex.at(ind), NORMAL_PIXEL);
+            else
+                (*go)[ind_i] = VertexProperties(ind_i, weight_vertex.at(ind), TOP_PIXEL);
+        }
+    }
+
+    if(rec == false){
+        std::ifstream fichier (edge_weight, std::ios::in);
+
+        if(fichier){
+            bool found;
+            edge_to e1;
+            int edge1, edge2;
+            double edge_weight;
+            int lines = std::count(std::istreambuf_iterator<char>( fichier ),std::istreambuf_iterator<char>(),'\n' );
+            //std::cout<<lines<<std::endl;
+            int cpt =0;
+            int length;
+            fichier.seekg(0, std::ios::beg);
+            while(cpt < lines){
+                fichier >> edge1 >> edge2 >> edge_weight;
+                tie(e1,found)=edge(vertex(edge1,*go),vertex(edge2,*go),*go);
+                (*go)[e1] = EdgeProperties(edge_weight);
+                //std::cout<<edge1<<" "<<edge2<<" "<<edge_weight<<std::endl;
+                length = fichier.tellg();
+                fichier.seekg(length+1, std::ios::beg);
+                cpt++;
+            }
+
+        }else{
+            // std::cerr<<"Bugggggg du fichier txt !!!! "<<std::endl;
+        }
+        fichier.close();
+    }
+}
+
+void build_example_ligne(OrientedGraph& og)
+{
+    vertex_to v0 = boost::add_vertex(og);
+    vertex_to v1 = boost::add_vertex(og);
+    vertex_to v2 = boost::add_vertex(og);
+    vertex_to v3 = boost::add_vertex(og);
+    vertex_to v4 = boost::add_vertex(og);
+    vertex_to v5 = boost::add_vertex(og);
+    vertex_to v6 = boost::add_vertex(og);
+    vertex_to v7 = boost::add_vertex(og);
+
+    add_edge(v0, v1, EdgeProperties(1.), og);
+    add_edge(v1, v2, EdgeProperties(1.), og);
+    add_edge(v2, v3, EdgeProperties(1.), og);
+    add_edge(v3, v4, EdgeProperties(1.), og);
+    add_edge(v4, v5, EdgeProperties(1.), og);
+    add_edge(v5, v6, EdgeProperties(1.), og);
+    add_edge(v6, v7, EdgeProperties(1.), og);
+
+    og[v6] = VertexProperties(6, 1, NORMAL_PIXEL);
+    og[v0] = VertexProperties(0, 1, TOP_PIXEL);
+    og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
+    og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
+    og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
+    og[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
+    og[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
+    og[v7] = VertexProperties(7, 1, NORMAL_PIXEL);
+}
+
+void build_example_grid(OrientedGraph& og)
+{
+    vertex_to v0 = boost::add_vertex(og);
+    vertex_to v1 = boost::add_vertex(og);
+    vertex_to v2 = boost::add_vertex(og);
+    vertex_to v3 = boost::add_vertex(og);
+    vertex_to v4 = boost::add_vertex(og);
+    vertex_to v5 = boost::add_vertex(og);
+    vertex_to v6 = boost::add_vertex(og);
+    vertex_to v7 = boost::add_vertex(og);
+
+    add_edge(v0, v1, EdgeProperties(0.9), og);
+    add_edge(v0, v2, EdgeProperties(0.9), og);
+    add_edge(v0, v3, EdgeProperties(0.1), og);
+    add_edge(v1, v2, EdgeProperties(0.1), og);
+    add_edge(v1, v3, EdgeProperties(0.9), og);
+    add_edge(v2, v3, EdgeProperties(0.9), og);
+    add_edge(v2, v4, EdgeProperties(0.9), og);
+    add_edge(v2, v5, EdgeProperties(0.1), og);
+    add_edge(v3, v4, EdgeProperties(0.1), og);
+    add_edge(v3, v5, EdgeProperties(0.9), og);
+    add_edge(v4, v5, EdgeProperties(0.9), og);
+    add_edge(v4, v6, EdgeProperties(0.9), og);
+    add_edge(v4, v7, EdgeProperties(0.1), og);
+    add_edge(v5, v6, EdgeProperties(0.1), og);
+    add_edge(v5, v7, EdgeProperties(0.9), og);
+    add_edge(v6, v7, EdgeProperties(0.9), og);
+
+    og[v6] = VertexProperties(6, 1, NORMAL_PIXEL);
+    og[v0] = VertexProperties(0, 1, TOP_PIXEL);
+    og[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
+    og[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
+    og[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
+    og[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
+    og[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
+    og[v7] = VertexProperties(7, 1, NORMAL_PIXEL);
+}
+
+void build_parcellaire_graph(OrientedGraph *go, uint size_max, std::string name)
+{
+    std::vector<std::pair<double,double> > point;
+    OrientedGraph::in_edge_iterator ei, edge_end;
+    double max_distance =  3000;//sqrt(2)*5*size_max/50;
+    double crit = sqrt(2)*5*size_max/1000;
+
+    // std::cout << "distance max : " << max_distance << std::endl;
+    // std::cout << "crit : " << crit << std::endl;
+    for(uint i = 0; i < size_max; i++)
+    {
+        std::pair<double,double> p;
+        p.first = rand()%(size_max*5-0) + 0;
+        p.second = rand()%(size_max*5-0) + 0;
+        point.push_back(p);
+    }
+
+    //std::cout << std::endl;
+    sort(point.begin(),point.end());
+    std::vector<std::vector<std::pair<double,uint> > > save_point_distance;
+
+    for(uint id = 0 ; id < point.size() - 1; id++)
+    {
+        std::vector<std::pair<double,uint> > point_distance, point_distance_sort;
+        //if(name != "multi"){
+        for(uint i = id +1 ; i < point.size(); i++)
+        {
+            std::pair<double,uint> pd;
+            pd.first = distance_t(point.at(id),point.at(i));
+            pd.second = i;
+            point_distance.push_back(pd);
+        }
+        /*}else{
+          for(uint i = 0 ; i < point.size(); i++)
+          {
+          std::pair<double,uint> pd;
+          pd.first = distance_t(point.at(id),point.at(i));
+          pd.second = i;
+          point_distance.push_back(pd);
+          }
+          }*/
+
+        point_distance_sort = point_distance;
+
+        sort(point_distance_sort.begin(), point_distance_sort.end());
+        std::vector<uint> deleted;
+        uint t;
+
+
+
+        if(point_distance_sort.size() > 50)
+            t = point_distance_sort.size()/2;
+        else
+            t = point_distance_sort.size();
+
+        /*if(name != "multi"){*/
+        for(uint i = 0 ; i < t; i++)
+        {
+            if(point_distance_sort.at(i).first < crit)
+                deleted.push_back(point_distance_sort.at(i).second);
+            //std::cout << point_distance_sort.at(i).second << " " << point_distance_sort.at(i).first <<std::endl;
+        }
+        /*}else{
+          for(uint i = 0 ; i < t; i++)
+          {
+          if(point_distance_sort.at(i).first < crit & point_distance_sort.at(i).first != 0)
+          deleted.push_back(point_distance_sort.at(i).second);
+          //std::cout << point_distance_sort.at(i).second << " " << point_distance_sort.at(i).first <<std::endl;
+          }
+          }*/
+        //std::cout<<std::endl;
+
+        sort(deleted.begin(), deleted.end());
+        std::reverse(deleted.begin(), deleted.end());
+
+        /*for(uint k = 0 ; k < deleted.size(); k++)
+          std::cout << deleted.at(k) << " " ;
+          std::cout<< std::endl << std::endl;*/
+
+        /*std::cout << "A : " << std::endl;
+          for(uint pp = 0; pp < point_distance.size(); pp++)
+          std::cout << point_distance.at(pp).second << " ";
+
+          std::cout<< std::endl << std::endl;*/
+
+        if(deleted.size() > 1)
+        {
+            //std::cout<<"Deleted"<<std::endl;
+            for(uint del = 0 ; del < deleted.size(); del++)
+            {
+                //std::cout << deleted.at(del) << " ";
+                for(uint idp = 0; idp < point_distance.size(); idp++)
+                {
+                    if(point_distance.at(idp).second == deleted.at(del))
+                    {
+                        //std::cout << idp + id + 1 << std::endl;
+                        /*if(name != "multi")
+                          {*/
+                        point.erase(point.begin() + idp + id + 1);
+                        point_distance.erase(point_distance.begin() + idp);
+                        for(uint pp = 0; pp < id ; pp++)
+                        {
+                            save_point_distance.at(pp).erase(save_point_distance.at(pp).begin() + idp);
+                            for(uint j = idp; j < save_point_distance.at(pp).size(); j++)
+                                save_point_distance.at(pp).at(j).second -=1;
+
+                        }
+                        for(uint j = idp; j < point_distance.size(); j++)
+                            point_distance.at(j).second -= 1;
+                        /*}else
+                          {
+                          point.erase(point.begin() + idp);
+                          point_distance.erase(point_distance.begin() + idp);
+                          for(uint pp = 0; pp < id ; pp++)
+                          {
+                          save_point_distance.at(pp).erase(save_point_distance.at(pp).begin() + idp);
+                          for(uint j = idp; j < save_point_distance.at(pp).size(); j++)
+                          save_point_distance.at(pp).at(j).second -=1;
+
+                          }
+                          for(uint j = idp; j < point_distance.size(); j++)
+                          point_distance.at(j).second -= 1;
+                          }*/
+                        break;
+                    }
+                }
+            }
+            //std::cout << std::endl;
+        }else if(deleted.size() == 1)
+        {
+            //std::cout<<"Deleted 2"<<std::endl;
+            //std::cout << deleted.at(0) << " ";
+            for(uint idp = 0; idp < point_distance.size(); idp++)
+            {
+
+                if(point_distance.at(idp).second == deleted.at(0))
+                {
+                    /*if(name != "multi")
+                      {*/
+                    //std::cout << idp + id + 1 << std::endl;
+                    point.erase(point.begin() + idp + id + 1);
+                    point_distance.erase(point_distance.begin() + idp);
+                    for(uint pp = 0; pp < id ; pp++)
+                    {
+                        save_point_distance.at(pp).erase(save_point_distance.at(pp).begin() + idp);
+                        for(uint j = idp; j < save_point_distance.at(pp).size(); j++)
+                            save_point_distance.at(pp).at(j).second -=1;
+
+                    }
+                    for(uint j = idp; j < point_distance.size(); j++)
+                        point_distance.at(j).second -= 1;
+                    //std::cout << " toto " << std::endl;
+
+                    /*}else{
+                      point.erase(point.begin() + idp);
+                      point_distance.erase(point_distance.begin() + idp);
+                      for(uint pp = 0; pp < id  ; pp++)
+                      {
+                      save_point_distance.at(pp).erase(save_point_distance.at(pp).begin() + idp);
+                      for(uint j = idp; j < save_point_distance.at(pp).size(); j++)
+                      save_point_distance.at(pp).at(j).second -=1;
+                      }
+                      for(uint j = idp; j < point_distance.size(); j++)
+                      point_distance.at(j).second -= 1;
+                      }*/
+                    break;
+                }
+            }
+            //std::cout << std::endl;
+        }
+        /*std::cout << " B : " << std::endl;
+          for(uint pp = 0; pp < point_distance.size(); pp++)
+          std::cout << point_distance.at(pp).second << " ";
+
+          std::cout << std::endl << std::endl;*/
+
+        //sort(point_distance.begin(), point_distance.end());
+        save_point_distance.push_back(point_distance);
+        //std::cout << std::endl;
+    }
+    // std::cout << "nombre de sommet" << point.size() << std::endl;
+
+
+    for(uint xt = 0; xt < save_point_distance.size(); xt++){
+        //std::cout << "** " << xt << " ** : ";
+        sort(save_point_distance.at(xt).begin(), save_point_distance.at(xt).end());
+        /*for(uint yt = 0; yt < save_point_distance.at(xt).size(); yt++){
+          std::cout << save_point_distance.at(xt).at(yt).first << " ";
+          }
+          std::cout << std::endl;*/
+    }
+
+
+    std::vector<vertex_to> Vertexs;
+    for(int i = 0; i < point.size(); i++){
+        vertex_to vo = boost::add_vertex(*go);
+        Vertexs.push_back(vo);
+    }
+
+    //std::cout << point.size() << std::endl;
+    for(int i = 0; i < point.size() -1; i++){
+        //std::cout << i << std::endl;
+        double dist = 0.;
+        uint xi;
+
+        //if(name != "multi")
+        xi = 0;
+        /*else
+          xi = 1;*/
+
+        while(dist < max_distance & xi < save_point_distance.at(i).size())
+        {
+            dist = save_point_distance.at(i).at(xi).first;
+            if(name != "multi")
+                add_edge(Vertexs.at(i), Vertexs.at(save_point_distance.at(i).at(xi).second), EdgeProperties(1.), *go);
+            else{
+                add_edge(Vertexs.at(i), Vertexs.at(save_point_distance.at(i).at(xi).second), EdgeProperties(1.), *go);
+                add_edge(Vertexs.at(save_point_distance.at(i).at(xi).second),Vertexs.at(i), EdgeProperties(1.), *go);
+            }
+            xi++;
+        }
+        (*go)[Vertexs.at(i)] = VertexProperties(i, 1., NORMAL_PIXEL);
+    }
+
+    (*go)[Vertexs.at(point.size()-1)] = VertexProperties(point.size()-1, 1., NORMAL_PIXEL);
+
+    /*std::cout << "ok"<< point.size() << std::endl;
+      for(int i = 0; i < (point.size() - arcs_max); i++)
+      {
+      std::cout << "ok"<< i << " "<< point.size() <<std::endl;
+      Entiers tmp_vector = Random_Sort_Vector2(i+1, point.size());
+      int ac = rand_fini(arcs_min, arcs_max);
+      std::cout << "! " << ac <<std::endl;
+      Entiers arcs;
+      for(uint p = 0; p < ac; p++)
+      arcs.push_back(tmp_vector.at(p));
+
+      //sort(arcs.begin(),arcs.end());
+
+      for(uint j = 0; j < arcs.size(); j++)
+      add_edge(Vertexs.at(i), Vertexs.at(arcs.at(j)), EdgeProperties(1.), *go);
+
+      (*go)[Vertexs.at(i)] = VertexProperties(i, 1., NORMAL_PIXEL);
+      }
+
+      std::cout << "ok1"<<std::endl;
+      for(int i = point.size() - arcs_max; i < point.size() - 2; i++)
+      {
+      Entiers tmp_vector = Random_Sort_Vector2(i+1,point.size());
+      int ac = rand_fini(1, 2);
+      Entiers arcs;
+      for(uint p = 0; p < ac; p++)
+      arcs.push_back(tmp_vector.at(p));
+
+      sort(arcs.begin(),arcs.end());
+
+      for(uint j = 0; j < arcs.size(); j++)
+      add_edge(Vertexs.at(i), Vertexs.at(arcs.at(j)), EdgeProperties(1.), *go);
+
+      (*go)[Vertexs.at(i)] = VertexProperties(i, 1., NORMAL_PIXEL);
+      }
+      std::cout << "ok2"<<std::endl;
+
+      add_edge(Vertexs.at(point.size()-2), Vertexs.at(point.size()-1), EdgeProperties(1.), *go);
+      (*go)[Vertexs.at(point.size()-2)] = VertexProperties(point.size()-2, 1., NORMAL_PIXEL);
+      (*go)[Vertexs.at(point.size()-1)] = VertexProperties(point.size()-1, 1., NORMAL_PIXEL);*/
+
+    for(uint i = 0; i< point.size(); i++){
+        bool indic = false;
+        for(tie(ei,edge_end) = in_edges(i,*go); ei != edge_end; ++ei){
+            indic = true;
+            break;
+        }
+        if(indic == false){
+            (*go)[i] = VertexProperties(i, 1, TOP_PIXEL);
+        }else{
+            (*go)[i] = VertexProperties(i, 1, NORMAL_PIXEL);
+        }
+        //std::cout<<(*go)[i]._index<<" "<<indic<<" -> "<<(*go)[i]._type<<std::endl;
+    }
+}
+
+/*void build_graph_grid_center(OrientedGraph *go, int side, const std::vector<std::pair<int,int>> &vertex_selection, const Entiers &weight_vertex,const char *edge_weight, bool rec){
+  int nbr_vertex = side*side;
+  std::vector<vertex_to> Vertexs;
+  for(int i =0; i<nbr_vertex; i++){
+  vertex_to vo = boost::add_vertex(*go);
+  Vertexs.push_back(vo);
+  }
+
+  // Ité 0
+  for(uint i = 0; i < 4; i++){
+  boost::add_edge(0, 2 + 2*i ,EdgeProperties(1) , *go);
+  }
+
+  // Ité 1
+
+  for(uint i = 1; i < 9; i++){
+
+  }
+
+
+
+  }*/
+
+/*Vérification de la pondération + vérification des poids de la contraction + vérification de la structure de contraction*/
+
 //void build_corsen_graph(OrientedGraph& graph);
 
 } } } // namespace paradevs tests boost_graph;

+ 5 - 4
src/tests/boost_graph/partitioning/main.cpp

@@ -24,6 +24,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <tests/boost_graph/graph_defs.hpp>
 #include <tests/boost_graph/partitioning/gggp.hpp>
 #include <tests/boost_graph/partitioning/graph_build.hpp>
 #include <boost/graph/copy.hpp>
@@ -34,11 +35,11 @@
 
 using namespace paradevs::tests::boost_graph;
 
-UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
-UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+// UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+// UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
 
-OrientedGraph::vertex_iterator vertexIto, vertexEndo;
-OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
+// OrientedGraph::vertex_iterator vertexIto, vertexEndo;
+// OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
 
 int main()
 {

+ 0 - 3446
src/tests/boost_graph/partitioning/utils.cpp

@@ -1,3446 +0,0 @@
-/**
- * @file tests/boost_graph/partitioning/utils.cpp
- * @author The PARADEVS Development Team
- * See the AUTHORS or Authors.txt file
- */
-
-/*
- * PARADEVS - the multimodeling and simulation environment
- * This file is a part of the PARADEVS environment
- *
- * Copyright (C) 2013-2015 ULCO http://www.univ-litoral.fr
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <tests/boost_graph/partitioning/utils.hpp>
-
-#include <algorithm>
-#include <iostream>
-#include <fstream>
-
-namespace paradevs { namespace tests { namespace boost_graph {
-
-UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
-UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
-
-OrientedGraph::vertex_iterator vertexIto, vertexEndo;
-OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
-
-struct myclass
-{
-    bool operator() (Entiers *i, Entiers *j)
-    { return i->at(0) < j->at(0); }
-} myobject;
-
-struct myclass2
-{
-    bool operator() (Entiers *i, Entiers *j, UnorientedGraph *g)
-    { return Calcul_poids(i,g) < Calcul_poids(j,g); }
-} mon_tri;
-
-struct myclass3
-{
-	bool operator() (Entiers *i, Entiers *j)
-	{ return i->size() > j->size(); }
-} myobject_taille;
-
-struct myclass4
-{
-    bool operator() (int i, int j, UnorientedGraph *g)
-    { return (*g)[i]._weight > (*g)[j]._weight; }
-} mon_poids;
-
-/**
- * Fonction de verification de la connexité d'un graphe
- * @param *g : adresse d'un graphe de type boost graphe undirected
- * @param Partition : vecteur contenant des vecteurs d'entiers [tableau contenant les parties de la partition]
- * @param part : vecteur d'entier (une partie de la partition)
- * @return un booleen
- */
-bool Est_connexe(UnorientedGraph *g, EntiersEntiers Partition, Entiers &part)
-{
-    /*
-     * Copie du graphe contenu par l'adresse *g
-     */
-    UnorientedGraph copie_g;
-    copie_g = *g;
-
-    /*
-     * Modification du graphe copié afin de générer des sous graphes liés aux différentes parties
-     */
-    for (uint i=0; i<Partition.size()-1;i++)
-    {
-        for (uint j=1+i; j<Partition.size();j++)
-        {
-            for (uint k=0; k<Partition.at(i)->size();k++)
-            {
-                for (uint y=0; y<Partition.at(j)->size();y++)
-                {
-                    remove_edge(Partition.at(i)->at(k),Partition.at(j)->at(y),copie_g); //suppression de certains arcs
-                }
-            }
-        }
-    }
-
-    /*
-     * Objectif : déterminer s'il existe un chemin reliant tous les noeuds d'une même partie
-     * Méthode : partir d'un sommet de départ tiré aléatoirement dans la partie "part" et parcourir l'ensemble de ces voisins.
-     * Si le voisin recontré n'est pas contenu dans le vecteur "sommets" il est ajouté. Le processus est répété pour chaque
-     * nouveau sommet ajouté au vecteur.
-     * Résultat : si le nombre de sommets contenu dans le vecteur "part" est égale au nombre de sommets du vecteur "sommets"
-     * alors le graphe est connexe
-     */
-
-    uint val;
-    Entiers sommets;
-
-    if(part.size()==1)
-        val = 0;
-    else
-        val=rand_fini(0,part.size()-1); //tirage aléatoire d'un sommets
-
-    uint vertex = part.at(val);
-    sommets.push_back(vertex); //ajout du sommets à la lsite des sommets parcouru
-
-    /*
-     * Recherche de voisins n'appartenant pas à la liste des sommets parcourus
-     */
-    for(uint i = 0;i<sommets.size();i++){
-        tie(neighbourIt, neighbourEnd) = adjacent_vertices(sommets.at(i),copie_g);
-        for (; neighbourIt != neighbourEnd; ++neighbourIt){
-            if(In_tab(sommets,*neighbourIt)!=1)
-                sommets.push_back(*neighbourIt);
-        }
-    }
-
-    /*
-     * Retour de la réponse vrai ou faux
-     */
-    if(part.size()!=sommets.size())
-        return false;
-    else
-        return true;
-
-}
-
-/**
- * Fonction de projection
- * @param Partition : vecteur contenant des vecteurs d'entiers [tableau contenant les parties de la partition]
- * @param lit : itérateur sur une liste contenant une vecteur de vecteur d'entier
- * @return
- */
-
-/*
- * Objectif : obtenir la correspondance entre les sommets d'un graphe Gn et celui de Gn-1
- * Méthode : modification des sommets contenus dans "Partition" à l'aide de la liste de correspondance *lit
- */
-
-void projection(EntiersEntiers &Partition,ListEntiersEntiers::iterator lit)
-{
-
-    /*
-     * Création d'un nouveau vecteur contenant les adresses d'autres vecteur d'entiers.
-     * Celui-ci est conçu pour recevoir les sommets contenus dans la liste de correspondance,
-     * correspondant à la projection des sommets du graphe Gn à celui de Gn-1
-     */
-    EntiersEntiers new_partition;
-    for(uint i = 0; i< Partition.size() ; i++)
-    {
-        Entiers *new_part = new Entiers();
-        for(uint j = 0 ; j<Partition.at(i)->size() ; j++)
-        {
-            for(uint k = 0; k<((*lit)->at(Partition.at(i)->at(j)))->size();k++){
-                new_part->push_back((*lit)->at(Partition.at(i)->at(j))->at(k));
-            }
-
-        }
-        new_partition.push_back(new_part);
-    }
-
-
-    /*
-     * Désalocation mémoire des pointeurs que contient "Partition"
-     */
-    for(EntiersEntiers::iterator it = Partition.begin(); it != Partition.end(); it++)
-    {
-        delete *it;
-        *it = NULL;
-    }
-
-    Partition = new_partition; // copie de new_partition dans Partition
-    for(uint i =0; i<Partition.size(); i++) {
-        // permet de trier chaque  sous vecteur de "Partition"
-        std::sort(Partition[i]->begin(),Partition[i]->end());
-    }
-
-    new_partition.clear();
-}
-
-/**
- * Fonction qui calcul le poids d'une partie
- * @param * part : adresse d'un vecteur d'entier, ici une partie de la partition
- * @param *g : adresse d'un graphe de type boost graphe undirected
- * @return un type double contenant le poids associé à la partie
- */
-double Calcul_poids(Entiers *partie, UnorientedGraph *g)
-{
-    double poids=0; // initialisation du poids à 0
-
-    /*
-     * Pour chaque sommet de la partie concerné on ajoute son poids au poids total
-     */
-    for(uint j = 0; j<partie->size();j++){
-        poids+=(*g)[partie->at(j)]._weight;
-    }
-
-    return poids;
-}
-
-/**
- * Fonction d'affinage suivant un critère de poids
- * @param *g : adresse d'un graphe de type boost graphe undirected
- * @param Partition : vecteur contenant des vecteurs d'entiers [tableau contenant les parties de la partition]
- * @return modification de la partition
- */
-void Affinage_equilibrage_charge(UnorientedGraph *g, EntiersEntiers &Partition)
-{
-    /*
-     * Calcule de la somme des poids du graphe et le poids moyen à atteindre
-     */
-    double poids_moyen = 0.;
-
-    for(uint i = 0; i < num_vertices(*g); i++) {
-        poids_moyen += (*g)[i]._weight;
-    }
-
-    // détermination du poids moyen à atteindre pour chaque partie
-    poids_moyen /= Partition.size();
-
-    std::vector < double > poids_parties;
-
-    /*
-     * Calcul du poids de chaque partie de la partition
-     */
-    for (uint i = 0; i < Partition.size(); i++) {
-        double tmp = Calcul_poids(Partition.at(i),g);
-
-        poids_parties.push_back(tmp);
-    }
-
-    std::clog << "Poids initial des parties : " << std::endl;
-
-    // for (uint i = 0; i < poids_parties.size(); i++){
-    //     std::cout << poids_parties.at(i) << " ";
-    // }
-    // std::cout << "\n" << std::endl;
-
-    /*
-     * Le critère d'amélioration consiste à faire tendre vers 0 la somme
-     * des écarts entre le poids des parties et le poids moyen
-     * le "critere" est la somme pour chaque partie de la différence
-     * en valeurs absolues du poids
-     * d'une partie moins le poids moyen divisé par le nombre de parties
-     */
-
-    double critere = 0.;
-
-    for (uint i = 0; i < poids_parties.size(); i++){
-        critere += abs(poids_parties.at(i) - poids_moyen);
-    }
-    critere /= Partition.size();
-
-    // on conserve le poids maximum
-    double p_max = *max_element(poids_parties.begin(), poids_parties.end());
-
-    // std::cout << "Valeurs du criètre de départ : " << critere << std::endl;
-
-    // création d'un second critère légérement plsu faible que le premier
-    double best_critere = critere - 1e-7;
-    uint nbr_passage = 1; // initialisation du nombre de passages à 1
-
-    /*
-     * Tant que le critère n'est pas amélioré etque le nombre de
-     * passage est inférieur au nombre de parties on réalise
-     * des modifications sur la partition
-     */
-    while (best_critere < critere or nbr_passage < Partition.size()) {
-        critere = best_critere; //critere devient best_critere
-
-        // recherche la partie associé au poids maximum
-        int cpt = recherche_val_double(poids_parties,p_max);
-        bool decision = false; //initialisatio d'un booleen a false
-        int nbr_pass_interne = 0;
-
-        /*
-         * tirage aléatoire des sommets de la partie de poids maximum
-         */
-        Entiers random_orders = Random_Sort_Vector(Partition.at(cpt)->size());
-
-        /*
-         * Si le nombre de sommets d'une partie excéde les 400, on tire au hasar 400 sommets sans remise
-         * et on effectue les modifications (ceci permet d'eviter une explosion des temps de calcul)
-         */
-        int size;
-
-        if(Partition.at(cpt)->size()>400)
-            size = 400;
-        else
-            size = Partition.at(cpt)->size();
-
-        /*
-         * Seconde boucle Tant que sur les sommets d'une partie.
-         * Tant que le critere booleen est vrai et que le nombre de passe interne est inférieur au seuil size faire
-         */
-        while(decision!=true && nbr_pass_interne < size){
-            int vertex = random_orders.at(nbr_pass_interne); //tirage d'un sommets dans la parite de poids maximum
-            Entiers community = Neigh_community(g,Partition,vertex,cpt); // recherche des communautés voisines à ce sommet (s'il est au bord)
-            if(community.size()!=0) // s'il existe au moins une communauté voisine
-            {
-                std::vector<double> new_poids_parties; // initialisation d'un nouveau vecteur contenant des doubles
-                std::vector<double> tmp_critere; // initialisation d'un nouveau vecteur contenant des doubles
-
-                /*
-                 * Pour chacune des parties (communauté) voisine au sommet vertexs faire
-                 */
-                for(uint k = 0; k < community.size();k++)
-                {
-                    new_poids_parties = poids_parties; //copie du tableau de poids des parties dans new_poids_parties
-
-                    /*
-                     * Modification des poids des parties :
-                     * on ajoute le poids du sommets à la partie voisine
-                     * et on soustrait son poids à sa partie d'origine
-                     */
-                    new_poids_parties.at(community.at(k))+=(*g)[vertex]._weight;
-                    new_poids_parties.at(cpt)-=(*g)[vertex]._weight;
-
-                    /*
-                     * Calcul ldu nouveau critère associé à cette modification
-                     */
-                    double new_critere = 0.;
-
-                    for(uint i = 0; i<poids_parties.size();i++){
-                        new_critere += abs(new_poids_parties.at(i)-poids_moyen);
-                    }
-                    new_critere/=Partition.size();
-                    tmp_critere.push_back(new_critere); // enregistrement du résutlat dans le tableau tmp_critere
-                }
-                double val_min = *min_element(tmp_critere.begin(),tmp_critere.end()); // enregistrement de la valeur minimale du tableau tmp_critere
-                int val = recherche_val_double(tmp_critere,val_min); // recherche de la communauté correspondant à cette valeur
-
-                /*
-                 * Si la valeur associé est plus petite et que la partie selectionné n'est pas vérouillée faire
-                 */
-                if(val_min<critere && poids_parties.at(val)!=-1)
-                {
-                    /*
-                     * On change le sommet vertex de partie, il est déplacé vers la partie
-                     * qui permet la meilleure amélioration du critère
-                     */
-                    Partition.at(community.at(val))->push_back(vertex);
-                    suprim_val(*Partition.at(cpt),vertex);
-                    std::sort(Partition.at(community.at(val))->begin(), Partition.at(community.at(val))->end());
-
-                    /*
-                     * Vérification de la sauvegarde de la connexsité,
-                     * si se n'est pas le cas retour à l'état précédent
-                     */
-                    if(Est_connexe(g,Partition,*Partition.at(cpt))!=1)
-                    {
-                        suprim_val(*Partition.at(community.at(val)),vertex);
-                        Partition.at(cpt)->push_back(vertex);
-                        std::sort(Partition.at(cpt)->begin(), Partition.at(cpt)->end());
-                        // std::cout<<" C'EST MORT RETOUR EN ARRIERE ! "<<std::endl
-                            ;
-                    }
-                    else
-                    {
-                        poids_parties = new_poids_parties;
-                        decision = true;
-                        // std::cout<<" Modification reussi ! "<<std::endl;
-                    }
-                }
-            }
-            nbr_pass_interne++;
-        }
-        /*
-         * Si aucune modification n'a été réalisé pour cett partie de poids maximum
-         */
-        if(decision==false)
-        {
-            nbr_passage++; // augmentation du nombre de passage
-            poids_parties.at(cpt)=-1; // vérrouillage de la partie
-            std::clog<<"nouveau passag ! "<<std::endl;
-        }
-        else
-        {
-            best_critere = 0.;
-
-            for(uint i = 0; i<poids_parties.size();i++){
-                best_critere += abs(poids_parties.at(i)-poids_moyen);
-            }
-            best_critere/=Partition.size();
-            nbr_passage = 0;
-        }
-
-        // std::clog<<"Poids des parties modifié : "<<std::endl;
-        // for(uint i = 0; i<poids_parties.size(); i++){
-        //     std::cout<<poids_parties.at(i)<<" ";
-        // }
-        // std::cout<<"\n"<<std::endl;
-        p_max = *max_element(poids_parties.begin(),poids_parties.end());
-        // std::cout<<"Valeurs du criètre : "<<critere<<std::endl;
-        // std::cout<<"Valeurs du best_criètre : "<<best_critere<<std::endl;
-        // std::cout<<"Nombre de passage : "<<nbr_passage<<std::endl;
-        // std::cout<<"\n"<<std::endl;
-
-    }
-}
-
-Entiers Neigh_community(UnorientedGraph *g, EntiersEntiers &Partition, int vertex, int comm_in)
-{
-    Entiers community;
-    int comm;
-    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex,*g);
-    for (; neighbourIt != neighbourEnd; ++neighbourIt){
-        comm = In_community_dichotomie(Partition,*neighbourIt);
-        if(In_tab(community,comm)!=1 && comm!=comm_in)
-            community.push_back(comm);
-    }
-    return community;
-}
-
-void Affinage_recherche_locale(UnorientedGraph *g, EntiersEntiers &Partition, double &cut, std::string name)
-{
-    Entiers random_orders = Random_Sort_Vector(num_vertices(*g)); //gestion d'un tableau contenant tout les sommets et ranger de façon aléatoire
-
-    uint size = random_orders.size();
-
-    if(num_vertices(*g)>500)
-        size=500;
-
-    std::vector<std::vector<double> > tabe_cut;
-
-    //std::cout<<"Passage : "<<Partition.size()<<std::endl;
-    for(uint k = 0; k < Partition.size();k++){
-        std::vector<double> tmp;
-        double vol = 0.;
-        double cut = Modif_Cut_one_cluster(*Partition.at(k), *g, vol, name);
-        tmp.push_back(cut);
-        tmp.push_back(vol);
-        tabe_cut.push_back(tmp);
-    }
-
-    for(uint i = 0; i < size; i++){
-        if(random_orders.at(i)!=-1){
-            int vertex = random_orders.at(i);
-            //std::cout<<vertex<<std::endl;
-            int comm = In_community_dichotomie(Partition, vertex);
-            Entiers community = Neigh_community(g,Partition,vertex,comm);
-            std::vector<double> tmp_cut;
-
-            if(community.size()!=0 && Partition.at(comm)->size()!=1){
-                tmp_cut = modif_cut_tmp(g,Partition,tabe_cut,vertex,comm,community,cut,name);
-                /*for(uint z = 0; z<tmp_cut.size(); z++){
-                    std::cout<<tmp_cut.at(z)<<std::endl;
-                }
-                std::cout<<"\n"<<std::endl;*/
-                double cut_min = *min_element(tmp_cut.begin(),tmp_cut.end());
-                //std::cout<<"cout de coupe minimum de la liste : "<<cut_min<<std::endl;
-                if(cut_min<cut){
-                    // std::clog<<"Changement ! "<<std::endl;
-                    int tmp = recherche_val_double(tmp_cut,cut_min);
-                    cut=cut_min;
-                    Partition.at(community.at(tmp))->push_back(vertex);
-                    suprim_val(*Partition.at(comm),vertex);
-                    std::sort(Partition.at(community.at(tmp))->begin(), Partition.at(community.at(tmp))->end());
-                    tabe_cut.clear();
-                    for(uint k = 0; k < Partition.size();k++){
-                        std::vector<double> tmp;
-                        double vol = 0.;
-                        double cut = Modif_Cut_one_cluster(*Partition.at(k), *g, vol, name);
-                        tmp.push_back(cut);
-                        tmp.push_back(vol);
-                        tabe_cut.push_back(tmp);
-                    }
-
-                }
-            }
-
-            Modif_fonction_Gain_Cut(Partition,g,community,vertex,cut,name);
-
-
-            /*if(Est_connexe(g,Partition,*Partition.at(comm))!=1)
-              {
-              suprim_val(*Partition.at(community.at(tmp)),vertex);
-              Partition.at(comm)->push_back(vertex);
-              std::sort(*Partition.at(comm));
-              std::cout<<" C'EST MORT RETOUR EN ARRIERE ! "<<std::endl;
-              }*/
-
-        }
-    }
-}
-
-double Modif_Cut_one_cluster(Entiers &cluster, UnorientedGraph &g, double &vol, std::string name)
-{
-	edge_t e1;
-	bool found;
-	double cpt= 0.;
-
-	if(name == "norm"){
-		for(uint i=0;i<cluster.size();i++){
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i), g);
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-				tie(e1,found)=edge(vertex(cluster[i],g),vertex(*neighbourIt,g),g);
-				if(In_tab(cluster,*neighbourIt)!=1){
-					cpt+=g[e1]._weight;
-				}
-			}
-		}
-		vol = Cluster_Degree(g,cluster);
-	} else if(name == "ratio"){
-		for(uint i=0;i<cluster.size();i++){
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i), g);
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-				tie(e1,found)=edge(vertex(cluster[i],g),vertex(*neighbourIt,g),g);
-				if(In_tab(cluster,*neighbourIt)!=1){
-					cpt+=g[e1]._weight;
-				}
-			}
-		}
-		vol = Cluster_Weight(g,cluster);
-	}
-	return cpt;
-
-}
-
-std::vector<double> modif_cut_tmp(UnorientedGraph *g, EntiersEntiers &Partition, std::vector<std::vector<double> > tabe_cut, int vertexs, int comm_in, Entiers community, double cut,std::string name){
-	edge_t e1;
-	bool found;
-	//std::cout<<"le sommet tiré est : "<<vertexs<<std::endl;
-
-	if(name == "cut")
-	{
-		std::vector<double> modif_cut(community.size());
-		double cpt_comm_in;
-		double cpt_comm_out;
-		for(uint i =0; i<community.size(); i++){
-			double tmp_cut = cut;
-			cpt_comm_in=0;
-			cpt_comm_out=0;
-
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs,*g);
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-				tie(e1,found)=edge(vertex(vertexs,*g),vertex(*neighbourIt,*g),*g);
-				if(In_tab(*Partition.at(comm_in),*neighbourIt)==1)
-					cpt_comm_in+=(*g)[e1]._weight;
-				else if(In_tab(*Partition.at(community.at(i)),*neighbourIt)==1)
-					cpt_comm_out+=(*g)[e1]._weight;
-			}
-
-			tmp_cut+=cpt_comm_in;
-			tmp_cut-=cpt_comm_out;
-
-			modif_cut.at(i)=tmp_cut;
-		}
-		return modif_cut;
-	}
-	else if(name == "norm"){
-		std::vector<double> modif_cut(community.size());
-		double cpt_comm_in;
-		double cpt_comm_out;
-		double tmp_cut;
-
-		for(uint i =0; i<community.size(); i++){
-			std::vector<std::vector<double> > tab_cut = tabe_cut;
-
-			tmp_cut =0.;
-			cpt_comm_in=0.;
-			cpt_comm_out=0.;
-
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs,*g);
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-				tie(e1,found)=edge(vertex(vertexs,*g),vertex(*neighbourIt,*g),*g);
-				if(In_tab(*Partition.at(comm_in),*neighbourIt)==1)
-					cpt_comm_in+=(*g)[e1]._weight;
-				else if(In_tab(*Partition.at(community.at(i)),*neighbourIt)==1)
-					cpt_comm_out+=(*g)[e1]._weight;
-			}
-
-			cpt_comm_in/=2.;
-			cpt_comm_out/=2.;
-
-			tab_cut.at(comm_in).at(0)+=cpt_comm_in;
-			tab_cut.at(comm_in).at(0)-=cpt_comm_out;
-			tab_cut.at(comm_in).at(1)-= Degree(*g ,vertexs);
-
-			tab_cut.at(community.at(i)).at(0)+=cpt_comm_in;
-			tab_cut.at(community.at(i)).at(0)-=cpt_comm_out;
-			tab_cut.at(community.at(i)).at(1)+= Degree(*g ,vertexs);
-
-			for(uint j = 0; j < tab_cut.size();j++){
-				tmp_cut+=((tab_cut.at(j).at(0))/(tab_cut.at(j).at(1)));
-			}
-
-			modif_cut.at(i)=tmp_cut;
-		}
-	}else if(name == "ratio"){
-		std::vector<double> modif_cut(community.size());
-		double cpt_comm_in;
-		double cpt_comm_out;
-		double tmp_cut;
-
-		for(uint i =0; i<community.size(); i++){
-			std::vector<std::vector<double> > tab_cut = tabe_cut;
-
-			tmp_cut =0.;
-			cpt_comm_in=0.;
-			cpt_comm_out=0.;
-
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs,*g);
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-				tie(e1,found)=edge(vertex(vertexs,*g),vertex(*neighbourIt,*g),*g);
-				if(In_tab(*Partition.at(comm_in),*neighbourIt)==1)
-					cpt_comm_in+=(*g)[e1]._weight;
-				else if(In_tab(*Partition.at(community.at(i)),*neighbourIt)==1)
-					cpt_comm_out+=(*g)[e1]._weight;
-			}
-
-			/*cpt_comm_in/=2.;
-			cpt_comm_out/=2.;*/
-
-			tab_cut.at(comm_in).at(0)+=cpt_comm_in;
-			tab_cut.at(comm_in).at(0)-=cpt_comm_out;
-			tab_cut.at(comm_in).at(1)-= (*g)[vertexs]._weight;
-
-			tab_cut.at(community.at(i)).at(0)+=cpt_comm_in;
-			tab_cut.at(community.at(i)).at(0)-=cpt_comm_out;
-			tab_cut.at(community.at(i)).at(1)+= (*g)[vertexs]._weight;
-
-			for(uint j = 0; j < tab_cut.size();j++){
-				tmp_cut+=((tab_cut.at(j).at(0))/(tab_cut.at(j).at(1)));
-			}
-
-			modif_cut.at(i)=tmp_cut;
-		}
-		return modif_cut;
-	}
-}
-void Modif_fonction_Gain_Cut(EntiersEntiers &Partition,UnorientedGraph *g, Entiers &community, int val, double &cut,std::string name)
-{
-	/*std::cout<<"Nombre de communauté voisine : "<<community.size()<<std::endl;
-	std::cout<<"\n"<<std::endl;*/
-	for(uint i = 0; i<community.size();i++){
-		EntiersEntiers new_partition;
-		for(uint k = 0; k < Partition.size();k++){
-			Entiers * tmp = new Entiers();
-			for(uint j = 0;j<Partition.at(k)->size();j++){
-				tmp->push_back(Partition.at(k)->at(j));
-			}
-			new_partition.push_back(tmp);
-		}
-
-
-		new_partition.at(community.at(i))->push_back(val);
-		suprim_val(*new_partition.at(In_community_dichotomie(Partition,val)),val);
-		std::sort(new_partition.at(community.at(i))->begin(),
-                    new_partition.at(community.at(i))->end());
-
-		double coupe = Cut_cluster(new_partition,*g,name);
-
-		//std::cout<<"cout de coupe : "<<coupe<<std::endl;
-		if(coupe<cut)
-		{
-			for(EntiersEntiers::iterator it = Partition.begin(); it != Partition.end(); it++)
-			{
-				delete *it;
-				*it = NULL;
-			}
-			Partition = new_partition;
-			cut = coupe;
-		}
-		else
-		{
-			for(EntiersEntiers::iterator it = new_partition.begin(); it != new_partition.end(); it++)
-			{
-				delete *it;
-				*it = NULL;
-			}
-		}
-	}
-}
-
-bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
-	UnorientedGraph *gtmp = new UnorientedGraph();
-	boost::copy_graph(*g, *gtmp);//, Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
-	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
-	edge_t e1,e2; // Iterateurs sur les arcs
-	bool found;
-	uint nbr_vertex = num_vertices(*gtmp);
-	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
-	/*
-	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
-	 * aléatoirement afin de simuler un tirage aléatoire
-	 */
-
-	Entiers Random_list_vertices = Random_Sort_Vector(nbr_vertex);
-
-	/*
-	 * Pour chaque sommet non verrouiller faire ....
-	 */
-
-	//std::cout<<"Nouvelle contraction !!!"<<std::endl;
-	//std::cout<<std::endl;
-	for(uint i=0; i<nbr_vertex; i++){
-		int vertexs = Random_list_vertices[i]; // Index_Vertex.at(Random_list_vertices.at(i));
-		//std::cout<<"Le sommet tiré est : "<<vertexs<<std::endl;
-		if(vertexs!=-1){
-			Entiers liste_voisin = Liste_adjacence(*gtmp,vertexs,Random_list_vertices); // Recherche des sommets adjacents au sommets  tiré
-			if(liste_voisin.size()!=0){
-				/*
-				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
-				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
-				 * le même poids, on selectionne le sommet d'index le plus petit
-				 */
-				double poids_a = 0.;
-				int best_vertexs = -1;
-				for(uint j=0;j<liste_voisin.size();j++){
-					tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
-					if((*gtmp)[e1]._weight>poids_a){
-						best_vertexs = liste_voisin[j];
-						poids_a = (*gtmp)[e1]._weight;
-					}
-				}
-
-
-				Entiers * couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
-				int vertex_delete = std::max(vertexs, best_vertexs); // Sommet d'index le plus grand (qui sera détruit)
-				//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
-				int vertex_save = std::min(vertexs,best_vertexs); // Sommet d'identifiant le plus petit (qui sera conservé)
-				//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
-
-				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
-				/*
-				 * On ajoute au tableau "couple" le couple de sommet à fusionner
-				 */
-				couple->push_back(vertex_save);
-				couple->push_back(vertex_delete);
-				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
-
-				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
-
-				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
-				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
-				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
-
-				/*
-				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
-				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
-				 * du processus]
-				 */
-				for (; neighbourIt != neighbourEnd; ++neighbourIt){
-					neigh_vertex_save.push_back(*neighbourIt);
-				}
-
-				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
-				for (; neighbourIt != neighbourEnd; ++neighbourIt){
-					neigh_vertex_delete.push_back(*neighbourIt);
-				}
-
-				/*
-				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
-				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
-				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
-				 */
-				for(uint j=0;j<neigh_vertex_delete.size();j++){
-					if(In_tab(neigh_vertex_save,neigh_vertex_delete[j])==1){
-						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
-						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
-					}
-					else
-					{
-						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
-						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
-					}
-				}
-
-				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
-				/*
-				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
-				 */
-				Random_list_vertices[i]=-1;
-				Random_list_vertices[recherche_val(Random_list_vertices,best_vertexs)]=-1;
-				val_cpt--;
-				// std::cout<<val_cpt<<std::endl;
-			}
-			else{
-				/*
-				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
-				 * alors on l'ajoute à la liste de correspondance des sommets et on
-				 * le verrouille
-				 */
-				Entiers *couple = new Entiers();
-				couple->push_back(Random_list_vertices.at(i));
-				tableau_de_correspondance->push_back(couple);
-				Random_list_vertices[i]=-1;
-			}
-		}
-
-		if(val_cpt == val_reduc){
-			for(uint j=i+1; j <nbr_vertex; j++){
-				if(Random_list_vertices[j] !=-1){
-				Entiers *couple = new Entiers();
-				couple->push_back(Random_list_vertices.at(j));
-				tableau_de_correspondance->push_back(couple);}
-			}
-			break;
-		}
-	}
-
-	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
-	// std::cout<<"\n"<<std::endl;
-	/*
-	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
-	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
-	 * des sommets
-	 */
-	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
-		//std::cout<<"Noeuds a supprimer : "<<sommets_a_detruire.at(j)<<std::endl;
-		remove_vertex(sommets_a_detruire[j],*gtmp);
-	}
-
-	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
-
-	liste_corr.push_back(tableau_de_correspondance);
-	// std::cout<<"\n"<<std::endl;
-	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
-
-	if(val_cpt == val_reduc)
-		return true;
-	else
-		return false;
-
-}
-
-bool contraction_HEM_tests(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
-	UnorientedGraph *gtmp = new UnorientedGraph();
-	boost::copy_graph(*g, *gtmp);
-	Entiers Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
-	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
-	edge_t e1,e2; // Iterateurs sur les arcs
-	bool found;
-	uint nbr_vertex = num_vertices(*gtmp);
-	//std::cout<<"val_reduc  : "<<val_reduc<<std::endl;
-	//std::cout<<"nbr_vertex : "<<nbr_vertex<<std::endl;
-	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
-	/*
-	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
-	 * aléatoirement afin de simuler un tirage aléatoire
-	 */
-	for (uint i=0 ; i<nbr_vertex ; i++)
-		Index_Vertex.push_back(i);
-
-	Entiers Random_list_vertices = Random_Sort_Vector(nbr_vertex);
-
-	/*
-	 * Pour chaque sommet non verrouiller faire ....
-	 */
-
-	//std::cout<<"Nouvelle contraction !!!"<<std::endl;
-	//std::cout<<std::endl;
-	for(uint i=0; i<nbr_vertex; i++){
-		int vertexs = Index_Vertex.at(Random_list_vertices.at(i));
-		//std::cout<<"Le sommet tiré est : "<<(*gtmp)[vertexs]._index<<" ça place est : "<<vertexs<<" place : "<<i<<std::endl;
-		if(vertexs!=-1){
-			Entiers liste_voisin = Liste_adjacence_tests(*gtmp,vertexs,Index_Vertex); // Recherche des sommets adjacents au sommets  tiré
-			if(liste_voisin.size()!=0){
-				/*
-				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
-				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
-				 * le même poids, on selectionne le sommet d'index le plus petit
-				 */
-				double poids_a = 0.;
-				int best_vertexs = -1;
-				for(uint j=0;j<liste_voisin.size();j++){
-					tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
-					if((*gtmp)[e1]._weight>poids_a){
-						best_vertexs = liste_voisin[j];
-						poids_a = (*gtmp)[e1]._weight;
-					}
-				}
-
-
-				Entiers *couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
-				int vertex_delete = std::max(vertexs, best_vertexs); // Sommet d'index le plus grand (qui sera détruit)
-				//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
-				int vertex_save = std::min(vertexs,best_vertexs); // Sommet d'identifiant le plus petit (qui sera conservé)
-				//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
-
-				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
-				/*
-				 * On ajoute au tableau "couple" le couple de sommet à fusionner
-				 */
-				couple->push_back(vertex_save);
-				couple->push_back(vertex_delete);
-				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
-
-				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
-
-				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
-				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
-				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
-
-				/*
-				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
-				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
-				 * du processus]
-				 */
-				for (; neighbourIt != neighbourEnd; ++neighbourIt){
-					neigh_vertex_save.push_back(*neighbourIt);
-					//std::cout<<(*gtmp)[*neighbourIt]._index<<" ";
-				}
-				//std::cout<<std::endl;
-				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
-				for (; neighbourIt != neighbourEnd; ++neighbourIt){
-					neigh_vertex_delete.push_back(*neighbourIt);
-					//std::cout<<(*gtmp)[*neighbourIt]._index<<" ";
-				}
-				//std::cout<<std::endl;
-
-				sort(neigh_vertex_save.begin(),neigh_vertex_save.end());
-				sort(neigh_vertex_delete.begin(),neigh_vertex_delete.end());
-				/*
-				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
-				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
-				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
-				 */
-
-				for(uint j=0;j<neigh_vertex_delete.size();j++){
-					//std::cout<<"* "<<neigh_vertex_delete.size()<<" "<<(*gtmp)[neigh_vertex_delete[j]]._index<<std::endl;
-					if(neigh_vertex_save.size() != 0){
-						if(In_tab_dichotomie(neigh_vertex_save,neigh_vertex_delete[j])==1){
-						//	std::cout<<"*p"<<std::endl;
-							tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-							tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-							(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
-							remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
-						}
-						else
-						{
-							//std::cout<<"*t"<<std::endl;
-							tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-							add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
-							remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
-						}
-					}else{
-						//std::cout<<"*t"<<std::endl;
-						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
-						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
-					}
-				}
-				//std::cout<<"**"<<std::endl;
-				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
-				/*
-				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
-				 */
-				Index_Vertex.at(Random_list_vertices.at(i))=-1;
-				Index_Vertex.at(best_vertexs)=-1;
-				val_cpt--;
-				//std::cout<<"***"<<std::endl;
-				//std::cout<<std::endl;
-			}
-			else{
-				/*
-				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
-				 * alors on l'ajoute à la liste de correspondance des sommets et on
-				 * le verrouille
-				 */
-				Entiers *couple = new Entiers();
-				couple->push_back(vertexs);
-				tableau_de_correspondance->push_back(couple);
-				Index_Vertex.at(Random_list_vertices.at(i))=-1;
-			}
-		}
-
-		if(val_cpt == val_reduc){
-			//std::cout<<"égalité"<<std::endl;
-			for(uint j=i+1; j < nbr_vertex; j++){
-				if(Index_Vertex.at(Random_list_vertices.at(j)) != -1){
-				Entiers *couple = new Entiers();
-				couple->push_back(Index_Vertex.at(Random_list_vertices.at(j)));
-				tableau_de_correspondance->push_back(couple);}
-			}
-			break;
-		}
-	}
-
-	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
-	// std::cout<<"\n"<<std::endl;
-	/*
-	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
-	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
-	 * des sommets
-	 */
-	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
-		//std::cout<<"Noeuds a supprimer : "<<sommets_a_detruire.at(j)<<std::endl;
-		remove_vertex(sommets_a_detruire[j],*gtmp);
-	}
-
-	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
-
-	liste_corr.push_back(tableau_de_correspondance);
-	// std::cout<<"\n"<<std::endl;
-	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
-
-	if(val_cpt == val_reduc)
-		return true;
-	else
-		return false;
-
-}
-
-bool contraction_HEM_max_degree_selection(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
-	UnorientedGraph *gtmp = new UnorientedGraph();
-	boost::copy_graph(*g, *gtmp);
-	Entiers Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
-	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
-	edge_t e1,e2; // Iterateurs sur les arcs
-	bool found;
-	uint nbr_vertex = num_vertices(*gtmp);
-	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
-	/*
-	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
-	 * aléatoirement afin de simuler un tirage aléatoire
-	 */
-	for (uint i=0 ; i<nbr_vertex ; i++)
-		Index_Vertex.push_back(i);
-
-	Entiers Random_list_vertices = Random_Sort_Vector(nbr_vertex);
-	/*
-	 * Pour chaque sommet non verrouiller faire ....
-	 */
-
-	//std::cout<<"Nouvelle contraction !!!"<<std::endl;
-	for(uint i=0; i<nbr_vertex; i++){
-		int vertexs = Index_Vertex.at(Random_list_vertices.at(i));
-		//std::cout<<"Le sommet tiré est : "<<(*gtmp)[vertexs]._index<<" ça place est : "<<Random_list_vertices.at(i)<<" place : "<<i<<std::endl;
-		if(vertexs!=-1){
-			Entiers liste_voisin = Liste_adjacence_tests(*gtmp,vertexs,Index_Vertex); // Recherche des sommets adjacents au sommets  tiré
-			if(liste_voisin.size()!=0){
-				/*
-				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
-				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
-				 * le même poids, on selectionne le sommet d'index le plus petit
-				 */
-				double poids_a = -1.;
-				int best_vertexs = -1;
-				for(uint j=0;j<liste_voisin.size();j++){
-					tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
-					if((*gtmp)[e1]._weight>poids_a){
-						best_vertexs = liste_voisin[j];
-						poids_a = (*gtmp)[e1]._weight;
-					}
-				}
-
-				Entiers *couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
-
-				/* Sélection  du sommet possedant un degrès maximum */
-				std::pair<double,int> couple1, couple2, best_min, best_max;
-				couple1.first = Degree(*gtmp,vertexs);
-				couple1.second = vertexs;
-				couple2.first = Degree(*gtmp,best_vertexs);
-				couple2.second = best_vertexs;
-				best_min = std::min(couple1,couple2);
-				best_max = std::max(couple1,couple2);
-				int vertex_delete = best_min.second; // Sommet d'index le plus grand (qui sera détruit)
-				//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
-				int vertex_save = best_max.second; // Sommet d'identifiant le plus petit (qui sera conservé)
-				//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
-
-				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
-				/*
-				 * On ajoute au tableau "couple" le couple de sommet à fusionner
-				 */
-				couple->push_back(vertex_save);
-				couple->push_back(vertex_delete);
-				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
-
-				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
-
-				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
-				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
-
-				/*
-				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
-				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
-				 * du processus]
-				 */
-				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
-				for (; neighbourIt != neighbourEnd; ++neighbourIt){
-						neigh_vertex_save.push_back(*neighbourIt);
-				}
-
-				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
-
-				for (; neighbourIt != neighbourEnd; ++neighbourIt){
-						neigh_vertex_delete.push_back(*neighbourIt);
-				}
-
-				sort(neigh_vertex_save.begin(),neigh_vertex_save.end());
-				sort(neigh_vertex_delete.begin(),neigh_vertex_delete.end());
-
-				/*
-				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
-				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
-				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
-				 */
-				for(uint j=0;j<neigh_vertex_delete.size();j++){
-					if(In_tab_dichotomie(neigh_vertex_save,neigh_vertex_delete[j])==1){
-						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
-						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
-					}
-					else
-					{
-						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
-						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
-					}
-				}
-
-				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
-				/*
-				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
-				 */
-				Index_Vertex.at(Random_list_vertices.at(i))=-1;
-				Index_Vertex.at(best_vertexs)=-1;
-				val_cpt--;
-			}
-			else{
-				/*
-				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
-				 * alors on l'ajoute à la liste de correspondance des sommets et on
-				 * le verrouille
-				 */
-				Entiers *couple = new Entiers();
-				couple->push_back(vertexs);
-				tableau_de_correspondance->push_back(couple);
-				Index_Vertex.at(Random_list_vertices.at(i))=-1;
-			}
-		}
-
-		if(val_cpt == val_reduc){
-			for(uint j=i+1; j < nbr_vertex; j++){
-				if(Index_Vertex.at(Random_list_vertices.at(j)) != -1){
-				Entiers *couple = new Entiers();
-				couple->push_back(Index_Vertex.at(Random_list_vertices.at(j)));
-				tableau_de_correspondance->push_back(couple);}
-			}
-			break;
-		}
-	}
-
-	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
-
-	/*
-	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
-	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
-	 * des sommets
-	 */
-
-	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
-		remove_vertex(sommets_a_detruire[j],*gtmp);
-	}
-
-	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
-	liste_corr.push_back(tableau_de_correspondance);
-	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
-
-	if(val_cpt == val_reduc)
-		return true;
-	else
-		return false;
-
-}
-
-bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
-	UnorientedGraph *gtmp = new UnorientedGraph();
-	boost::copy_graph(*g, *gtmp);
-	Entiers Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
-	std::vector<double> vertex_degree;
-	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
-	edge_t e1,e2; // Iterateurs sur les arcs
-	bool found;
-	uint nbr_vertex = num_vertices(*gtmp);
-	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
-	int cpt = nbr_vertex;
-	/*
-	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
-	 * aléatoirement afin de simuler un tirage aléatoire
-	 */
-
-	for (uint i=0 ; i<nbr_vertex ; i++){
-		Index_Vertex.push_back(i);
-		vertex_degree.push_back(Degree(*g,i));
-	}
-
-	while(cpt != 0){
-		double max_weight = *std::max_element(vertex_degree.begin(),vertex_degree.end());
-		int vertexs, compteur;
-		//std::cout<<"max_weight : "<<max_weight<<std::endl;
-		//Entiers Vertex_select;
-		for(uint id = 0; id <vertex_degree.size(); id++){
-			if(vertex_degree.at(id) == max_weight){
-				compteur = id;
-				vertexs = Index_Vertex.at(id);
-				break;
-			}
-		}
-		//std::cout<<"min : "<<max_weight<<" - compteur : "<<(*gtmp)[compteur]._index;
-
-		//std::cout<<"Le sommet tiré est : "<<(*gtmp)[vertexs]._index<<" ça place est : "<<compteur<<std::endl;
-		Entiers liste_voisin = Liste_adjacence_tests(*gtmp,vertexs,Index_Vertex); // Recherche des sommets adjacents au sommets  tiré
-		if(liste_voisin.size() != 0){
-			/*
-			 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
-			 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
-			 * le même poids, on selectionne le sommet d'index le plus petit
-			 */
-			std::vector<double> Neight_weight, Best_neight;
-			int best_vertexs;
-			for(uint j=0;j<liste_voisin.size();j++){
-				tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
-				Neight_weight.push_back((*gtmp)[e1]._weight);
-			}
-
-			max_weight = *std::max_element(Neight_weight.begin(),Neight_weight.end());
-			for(uint j=0;j<liste_voisin.size();j++){
-				if(Neight_weight.at(j) == max_weight)
-					Best_neight.push_back(liste_voisin.at(j));
-			}
-
-			if(Best_neight.size() > 1){
-				int ind;
-				double deg =1000000000;
-				double tmp_deg;
-				for(uint j=0;j<Best_neight.size();j++){
-					tmp_deg = Degree(*gtmp,Best_neight.at(j));
-					if(tmp_deg < deg){
-						deg = tmp_deg;
-						ind = j;
-					}
-				}
-				best_vertexs = Best_neight.at(ind);
-			}else{
-				best_vertexs = Best_neight.at(0);
-			}
-
-			//std::cout<<" -> "<<(*gtmp)[best_vertexs]._index;
-			Entiers *couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
-
-			/* Sélection  du sommet possedant un degrès maximum */
-			std::pair<double,int> couple1, couple2, best_min, best_max;
-			couple1.first = Degree(*gtmp,vertexs);
-			couple1.second = vertexs;
-			couple2.first = Degree(*gtmp,best_vertexs);
-			couple2.second = best_vertexs;
-			best_min = std::min(couple1,couple2);
-			best_max = std::max(couple1,couple2);
-			int vertex_delete = best_min.second; // Sommet d'index le plus grand (qui sera détruit)
-			//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
-			int vertex_save = best_max.second; // Sommet d'identifiant le plus petit (qui sera conservé)
-			//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
-
-			sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
-			/*
-			 * On ajoute au tableau "couple" le couple de sommet à fusionner
-			 */
-			couple->push_back(vertex_save);
-			couple->push_back(vertex_delete);
-			tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
-
-			remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
-
-			Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
-			Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
-
-			/*
-			 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
-			 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
-			 * du processus]
-			 */
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-					neigh_vertex_save.push_back(*neighbourIt);
-			}
-
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
-
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-					neigh_vertex_delete.push_back(*neighbourIt);
-			}
-
-			sort(neigh_vertex_save.begin(),neigh_vertex_save.end());
-			sort(neigh_vertex_delete.begin(),neigh_vertex_delete.end());
-
-			/*
-			 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
-			 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
-			 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
-			 */
-			for(uint j=0;j<neigh_vertex_delete.size();j++){
-				if(neigh_vertex_save.size() != 0){
-					if(In_tab_dichotomie(neigh_vertex_save,neigh_vertex_delete[j])==1){
-						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
-						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
-					}
-					else
-					{
-						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
-						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
-					}
-				}else{
-					tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-					add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
-					remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
-				}
-			}
-
-			(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
-			/*
-			 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
-			 */
-			Index_Vertex.at(compteur)=-1;
-			vertex_degree.at(compteur)=-1;
-			Index_Vertex.at(best_vertexs)=-1;
-			vertex_degree.at(best_vertexs)=-1;
-			val_cpt--;
-			cpt -= 2;
-			//std::cout<<" ** "<<std::endl;
-			//std::cout<<cpt<<std::endl;
-		}
-		else{
-			/*
-			 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
-			 * alors on l'ajoute à la liste de correspondance des sommets et on
-			 * le verrouille
-			 */
-			Entiers *couple = new Entiers();
-			couple->push_back(vertexs);
-			tableau_de_correspondance->push_back(couple);
-			Index_Vertex.at(compteur)=-1;
-			vertex_degree.at(compteur)=-1;
-			cpt --;
-			//std::cout<<" * "<<std::endl;
-		}
-
-		if(val_cpt == val_reduc){
-			for(uint j=0; j < nbr_vertex; j++){
-				if(Index_Vertex.at(j) != -1){
-				Entiers *couple = new Entiers();
-				couple->push_back(Index_Vertex.at(j));
-				tableau_de_correspondance->push_back(couple);}
-			}
-			break;
-		}
-	}
-
-	//std::cout<<"cpt : "<<cpt<<std::endl;
-	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
-
-	/*
-	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
-	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
-	 * des sommets
-	 */
-
-	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
-		remove_vertex(sommets_a_detruire[j],*gtmp);
-	}
-
-	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
-	liste_corr.push_back(tableau_de_correspondance);
-	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
-
-	if(val_cpt == val_reduc)
-		return true;
-	else
-		return false;
-
-}
-
-bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
-	UnorientedGraph *gtmp = new UnorientedGraph();
-	boost::copy_graph(*g, *gtmp);
-	Entiers Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
-	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
-	edge_t e1,e2; // Iterateurs sur les arcs
-	bool found;
-	uint nbr_vertex = num_vertices(*gtmp);
-	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
-	/*
-	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
-	 * aléatoirement afin de simuler un tirage aléatoire
-	 */
-	for (uint i=0 ; i<nbr_vertex ; i++)
-		Index_Vertex.push_back(i);
-
-	Entiers Random_list_vertices = Random_Sort_Vector(nbr_vertex);
-
-	/*
-	 * Pour chaque sommet non verrouiller faire ....
-	 */
-
-	//std::cout<<"Nouvelle contraction !!!"<<std::endl;
-	for(uint i=0; i<nbr_vertex; i++){
-		int vertexs = Index_Vertex.at(Random_list_vertices.at(i));
-		//std::cout<<"Le sommet tiré est : "<<(*gtmp)[vertexs]._index<<" ça place est : "<<Random_list_vertices.at(i)<<" place : "<<i<<std::endl;
-		if(vertexs!=-1){
-			Entiers liste_voisin = Liste_adjacence_tests(*gtmp,vertexs,Index_Vertex); // Recherche des sommets adjacents au sommets  tiré
-			sort(liste_voisin.begin(),liste_voisin.end());
-			if(liste_voisin.size()!=0){
-				/*
-				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
-				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
-				 * le même poids, on selectionne le sommet d'index le plus petit
-				 */
-				/*std::cout<<"Le sommet tiré a des voisins "<<std::endl;
-				for(uint id = 0; id<liste_voisin.size(); id++){
-					std::cout<<(*gtmp)[liste_voisin.at(id)]._index<<" ";
-				}
-				std::cout<<std::endl;*/
-				double poids_a = -1.;
-				std::vector<double> adjacent_weight;
-				//std::cout<<"adjacent_weight"<<std::endl;
-				for(uint j=0;j<liste_voisin.size();j++){
-					tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
-					adjacent_weight.push_back((*gtmp)[e1]._weight);
-					//std::cout<<(*gtmp)[e1]._weight<<" ";
-				}
-				//std::cout<<std::endl;
-				//std::cout<<"Top *"<<std::endl;
-				double max_weight = *std::max_element(adjacent_weight.begin(),adjacent_weight.end());
-				//std::cout<<"max_weight : "<<max_weight<<std::endl;
-				Entiers Vertex_select;
-				for(uint id = 0; id <adjacent_weight.size(); id++){
-					if(adjacent_weight.at(id) == max_weight)
-						Vertex_select.push_back(liste_voisin.at(id));
-				}
-
-				int index = 0;
-				if(Vertex_select.size()>1){
-					//std::cout<<"Top **"<<std::endl;
-					for(uint id = 0; id<Vertex_select.size(); id++){
-						suprim_val(liste_voisin,Vertex_select.at(id)); /*** modification possible ***/
-					}
-
-					//std::cout<<"Top ***"<<std::endl;
-					adjacent_weight.clear();
-					for(uint id_Vs = 0; id_Vs<Vertex_select.size(); id_Vs++){
-						double neigh_weight = 0.;
-						for(uint id_Lv = 0; id_Lv<liste_voisin.size(); id_Lv++){
-							//std::cout<<"Top ***!"<<std::endl;
-							bool rep = Est_voisin(gtmp,liste_voisin.at(id_Lv),Vertex_select.at(id_Vs));
-							if(rep == true){
-								tie(e1,found)=edge(vertex(Vertex_select.at(id_Vs),*gtmp),vertex(liste_voisin.at(id_Lv),*gtmp),*gtmp);
-								//std::cout<<"Top ***!!"<<std::endl;
-								//std::cout<<e1<<std::endl;
-								//std::cout<<"Top ***!!!"<<std::endl;
-								neigh_weight += (*gtmp)[e1]._weight;
-							}
-							//std::cout<<"Top ***!!!!"<<std::endl;
-						}
-						adjacent_weight.push_back(neigh_weight);
-					}
-
-					//std::cout<<"Top ****"<<std::endl;
-					max_weight = *std::max_element(adjacent_weight.begin(),adjacent_weight.end());
-					for(uint id = 0; id <adjacent_weight.size(); id++){
-						if(adjacent_weight.at(id) == max_weight){
-							index = id;
-							break;
-						}
-					}
-				}
-
-				//std::cout<<"Index "<<index<<std::endl;
-				//std::cout<<"Top *****"<<std::endl;
-				int best_vertexs = Vertex_select.at(index);
-				//std::cout<<"Index "<<best_vertexs<<std::endl;
-				Entiers *couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
-
-				/* Sélection  du sommet possedant un degrès maximum */
-				std::pair<double,int> couple1, couple2, best_min, best_max;
-				couple1.first = Degree(*gtmp,vertexs);
-				couple1.second = vertexs;
-				couple2.first = Degree(*gtmp,best_vertexs);
-				couple2.second = best_vertexs;
-				best_min = std::min(couple1,couple2);
-				best_max = std::max(couple1,couple2);
-				int vertex_delete = best_min.second; // Sommet d'index le plus grand (qui sera détruit)
-				//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
-				int vertex_save = best_max.second; // Sommet d'identifiant le plus petit (qui sera conservé)
-				//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
-
-				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
-				/*
-				 * On ajoute au tableau "couple" le couple de sommet à fusionner
-				 */
-				couple->push_back(vertex_save);
-				couple->push_back(vertex_delete);
-				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
-
-				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
-
-				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
-				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
-
-				/*
-				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
-				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
-				 * du processus]
-				 */
-				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
-				for (; neighbourIt != neighbourEnd; ++neighbourIt){
-						neigh_vertex_save.push_back(*neighbourIt);
-				}
-
-				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
-				for (; neighbourIt != neighbourEnd; ++neighbourIt){
-						neigh_vertex_delete.push_back(*neighbourIt);
-				}
-
-				sort(neigh_vertex_save.begin(),neigh_vertex_save.end());
-				sort(neigh_vertex_delete.begin(),neigh_vertex_delete.end());
-
-				/*
-				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
-				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
-				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
-				 */
-				for(uint j=0;j<neigh_vertex_delete.size();j++){
-					if(In_tab_dichotomie(neigh_vertex_save,neigh_vertex_delete[j])==1){
-						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
-						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
-					}
-					else
-					{
-						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
-						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
-					}
-				}
-
-				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
-				/*
-				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
-				 */
-				Index_Vertex.at(Random_list_vertices.at(i))=-1;
-				Index_Vertex.at(best_vertexs)=-1;
-				val_cpt--;
-			}
-			else{
-				/*
-				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
-				 * alors on l'ajoute à la liste de correspondance des sommets et on
-				 * le verrouille
-				 */
-				//std::cout<<"Le sommet tiré est isolé "<<std::endl;
-				Entiers *couple = new Entiers();
-				couple->push_back(vertexs);
-				tableau_de_correspondance->push_back(couple);
-				Index_Vertex.at(Random_list_vertices.at(i))=-1;
-			}
-		}else{
-			//std::cout<<"Le sommet est bloqué "<<std::endl;
-			//std::cout<<" ça place est : "<<Random_list_vertices.at(i)<<" valeur : "<<Index_Vertex.at(Random_list_vertices.at(i))<<std::endl;
-		}
-
-		if(val_cpt == val_reduc){
-			//std::cout<<"Taille obtenue !"<<std::endl;
-			for(uint j=i+1; j < nbr_vertex; j++){
-				if(Index_Vertex.at(Random_list_vertices.at(j)) != -1){
-				Entiers *couple = new Entiers();
-				couple->push_back(vertexs);
-				tableau_de_correspondance->push_back(couple);}
-			}
-			break;
-		}
-	}
-
-	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
-
-	/*
-	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
-	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
-	 * des sommets
-	 */
-
-	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
-		remove_vertex(sommets_a_detruire[j],*gtmp);
-	}
-
-	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
-	liste_corr.push_back(tableau_de_correspondance);
-	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
-
-	if(val_cpt == val_reduc)
-		return true;
-	else
-		return false;
-
-}
-
-bool Est_voisin(UnorientedGraph *g, int vertex, int vertex_select){
-	bool reponse = false;
-
-	tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex, *g);
-	for (; neighbourIt != neighbourEnd; ++neighbourIt){
-		if(*neighbourIt == vertex_select)
-			reponse = true;
-	}
-	return reponse;
-}
-
-bool contraction_Random_Maching(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
-	UnorientedGraph *gtmp = new UnorientedGraph();
-	boost::copy_graph(*g, *gtmp);
-	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
-	edge_t e1,e2; // Iterateurs sur les arcs
-	bool found;
-	uint nbr_vertex = num_vertices(*gtmp);
-	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
-
-	/*
-	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
-	 * aléatoirement afin de simuler un tirage aléatoire
-	 */
-	Entiers Random_list_vertices = Random_Sort_Vector(nbr_vertex);
-
-	/*
-	 * Pour chaque sommet non verrouiller faire ....
-	 */
-	for(uint i=0; i<nbr_vertex; i++){
-		int vertexs = Random_list_vertices[i];
-		if(vertexs!=-1){
-			Entiers liste_voisin = Liste_adjacence(*gtmp,vertexs,Random_list_vertices); // Recherche des sommets adjacents au sommets  tiré
-			if(liste_voisin.size()!=0){
-				/*
-				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
-				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
-				 * le même poids, on selectionne le sommet d'identifiant le plus petit
-				 */
-				int tmp;
-				if(liste_voisin.size()==1)
-					tmp = 0;
-				else
-					tmp = rand_fini(0,liste_voisin.size()-1);
-
-				int best_vertexs = liste_voisin.at(tmp);
-
-				Entiers * couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
-				int vertex_delete = std::max(vertexs, best_vertexs); // Sommet d'indentifiant le plus grand (qui sera détruit)
-				int vertex_save = std::min(vertexs,best_vertexs); // Sommet d'identifiant le plus petit (qui sera conservé)
-
-				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
-				/*
-				 * On ajoute au tableau "couple" le couple de sommet à fusionner
-				 */
-				couple->push_back(vertex_save);
-				couple->push_back(vertex_delete);
-				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
-
-				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
-
-				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les somemts adjacents au "sommet sauvegardé"
-				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
-				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
-
-				/*
-				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
-				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
-				 * du processus]
-				 */
-				for (; neighbourIt != neighbourEnd; ++neighbourIt){
-					neigh_vertex_save.push_back(*neighbourIt);
-				}
-
-				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
-				for (; neighbourIt != neighbourEnd; ++neighbourIt){
-					neigh_vertex_delete.push_back(*neighbourIt);
-				}
-
-				/*
-				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
-				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
-				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
-				 */
-				for(uint j=0;j<neigh_vertex_delete.size();j++){
-					if(In_tab(neigh_vertex_save,neigh_vertex_delete[j])==1){
-						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
-						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
-					}
-					else
-					{
-						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
-						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
-						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
-					}
-				}
-
-				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
-				/*
-				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
-				 */
-				Random_list_vertices[i]=-1;
-				Random_list_vertices[recherche_val(Random_list_vertices,best_vertexs)]=-1;
-				val_cpt--;
-				// std::cout<<val_cpt<<std::endl;
-			}
-			else{
-				/*
-				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
-				 * alors on l'ajoute à la liste de correspondance des sommets et on
-				 * le verrouille
-				 */
-				Entiers *couple = new Entiers();
-				couple->push_back(Random_list_vertices.at(i));
-				tableau_de_correspondance->push_back(couple);
-				Random_list_vertices[i]=-1;
-			}
-		}
-		if(val_cpt == val_reduc){
-			for(uint j=i+1; j <nbr_vertex; j++){
-				if(Random_list_vertices[j] !=-1){
-				Entiers *couple = new Entiers();
-				couple->push_back(Random_list_vertices.at(j));
-				tableau_de_correspondance->push_back(couple);}
-			}
-			break;
-		}
-	}
-
-	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
-	//std::cout<<"\n"<<std::endl;
-	/*
-	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
-	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
-	 * des sommets
-	 */
-	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
-		//std::cout<<"Noeuds a supprimer : "<<sommets_a_detruire.at(j)<<std::endl;
-		remove_vertex(sommets_a_detruire[j],*gtmp);
-	}
-
-	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
-	liste_corr.push_back(tableau_de_correspondance);
-	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
-
-
-	if(val_cpt == val_reduc)
-		return true;
-	else
-		return false;
-
-}
-
-Entiers Liste_adjacence(UnorientedGraph &g, int vertexs,const Entiers &random_vertices){ // a revoir !!!!
-	Entiers liste_voisin;
-	tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs, g);
-	for (; neighbourIt != neighbourEnd; ++neighbourIt){
-		if(In_tab(random_vertices,*neighbourIt)==1)
-			liste_voisin.push_back(*neighbourIt);
-	}
-	return liste_voisin;
-}
-
-Entiers Liste_adjacence_tests(UnorientedGraph &g, int vertexs,const Entiers &Index_Vertex){ // a revoir !!!!
-	Entiers liste_voisin;
-	tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs, g);
-	for (; neighbourIt != neighbourEnd; ++neighbourIt){
-		if(Index_Vertex.at(*neighbourIt)!=-1)
-			liste_voisin.push_back(*neighbourIt);
-	}
-	return liste_voisin;
-}
-
-int rand_fini(int a, int b){
-	return rand()%(b-a)+a;
-}
-
-/**
- * Fonction de recherche d'une valeur dans un tableau.
- * @param tab
- * @param val
- * @return
- */
-int recherche_val2(const std::vector<float> &tab,float val){
-	int cpt=0;
-	while(tab[cpt]!=val)
-		cpt++;
-	return cpt;
-}
-
-int recherche_val_double(const std::vector<double> &tab,double val){
-	int cpt=0;
-	while(tab[cpt]!=val)
-		cpt++;
-	return cpt;
-}
-
-int recherche_val(const Entiers &tab,int val){
-	int cpt=0;
-	while(tab[cpt]!=val)
-		cpt++;
-	return cpt;
-}
-/**
- * @param tab
- * @param i
- * @return
- */
-int dichotomie(const Entiers &tab, int i){
-
-	/* déclaration des variables locales à la fonction */
-	int id;  //indice de début
-	int ifin;  //indice de fin
-	int im;  //indice de "milieu"
-
-	/* initialisation de ces variables avant la boucle de recherche */
-	id = 0;  //intervalle de recherche compris entre 0...
-	ifin = tab.size();  //...et nbVal
-
-	/* boucle de recherche */
-	while ((ifin - id) > 1){
-		im = (id + ifin)/2;  //on détermine l'indice de milieu
-		if(tab[im] > i) ifin = im;  //si la valeur qui est à la case "im" est supérieure à la valeur recherchée, l'indice de fin "ifin" << devient >> l'indice de milieu, ainsi l'intervalle de recherche est restreint lors du prochain tour de boucle
-		else id = im;  //sinon l'indice de début << devient >> l'indice de milieu et l'intervalle est de la même façon restreint
-	}
-
-	/* test conditionnant la valeur que la fonction va renvoyer */
-	if (tab[id] == i) return id;  //si on a trouvé la bonne valeur, on retourne l'indice
-	else return -1;  //sinon on retourne -1
-
-}
-
-/**
- * Fonction permettant de supprimer une case d'un tableau.
- * @param tab une référence sur un tableau d'entiers
- * @param i un indice dans tab
- */
-void suprim_val(Entiers &tab,int i) {
-	tab.erase(tab.begin() + dichotomie(tab,i));
-}
-
-/**
- * Détermine si une valeur se trouve dans un tableau.
- * @param tab une référence sur un tableau d'entiers
- * @param val une valeur
- * @return true si la valeur a été trouvée, false sinon
- */
-bool In_tab(const Entiers &tab, int val)
-{
-	for (uint i=0; i < tab.size(); i++)
-		if(tab[i]==val)
-			return true;
-	return false;
-}
-
-bool In_tab_dichotomie(const Entiers &tab, int val)
-{
-	if(dichotomie(tab,val)!=-1)
-		return true;
-	else
-		return false;
-}
-
-
-void Liste_Voisin(const Entiers &P,Entiers &tab,const UnorientedGraph &g)
-{
-	tie(neighbourIt, neighbourEnd) = adjacent_vertices(P.at(P.size()-1), g);
-	for (; neighbourIt != neighbourEnd; ++neighbourIt)
-	{
-		if((In_tab(tab,*neighbourIt) == false ) && (In_tab(P,*neighbourIt) == false ))
-			tab.push_back(*neighbourIt);
-	}
-}
-
-int Cout_coupe(Entiers P,int val, UnorientedGraph &g)
-{
-	int cpt=0;
-	P.push_back(val);
-	for(uint i=0;i<P.size();i++){
-		tie(neighbourIt, neighbourEnd) = adjacent_vertices(P[i], g);
-		for (; neighbourIt != neighbourEnd; ++neighbourIt){
-			if(In_tab(P,*neighbourIt)!=1){
-				cpt++;
-			}
-		}
-	}
-	return cpt;
-}
-
-double Cut_one_cluster(const Entiers &cluster, UnorientedGraph &g, std::string name)
-{
-	if(name=="norm"){
-		edge_t e1;
-		bool found;
-		double cpt=0.;
-		for(uint i=0;i<cluster.size();i++){
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i), g);
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-				tie(e1,found)=edge(vertex(cluster[i],g),vertex(*neighbourIt,g),g);
-				if(In_tab(cluster,*neighbourIt)!=1){
-					cpt+=g[e1]._weight;
-				}
-			}
-		}
-		double deg = Cluster_Degree(g,cluster);
-		return cpt/deg;
-	}
-	else if(name == "cut"){
-		edge_t e1;
-		bool found;
-		double cpt=0.;
-		for(uint i=0;i<cluster.size();i++){
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i), g);
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-				tie(e1,found)=edge(vertex(cluster.at(i),g),vertex(*neighbourIt,g),g);
-				if(In_tab(cluster,*neighbourIt)!=1){
-					cpt+=g[e1]._weight;
-				}
-			}
-		}
-		return cpt/2.;
-	}
-	else if(name == "ratio"){
-		edge_t e1;
-		bool found;
-		double cpt=0.;
-		for(uint i=0;i<cluster.size();i++){
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i), g);
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-				tie(e1,found)=edge(vertex(cluster.at(i),g),vertex(*neighbourIt,g),g);
-				if(In_tab(cluster,*neighbourIt)!=1){
-					cpt+=g[e1]._weight;
-				}
-			}
-		}
-		double vol = Cluster_Weight(g,cluster);
-		return (cpt/2.)/vol;
-	}
-
-	/*Vérification de la formule : doute sur le /2.*/
-}
-
-double Cut_cluster(const EntiersEntiers &tab_cluster,UnorientedGraph &g,std::string name)
-{
-	double cpt=0.;
-	for(uint i=0;i<tab_cluster.size();i++){
-		cpt+=Cut_one_cluster(*tab_cluster[i],g,name);
-	}
-	return cpt;
-}
-
-double Cout_coupe_pond(Entiers P, int val, UnorientedGraph &g)
-{
-    edge_t e1;
-    bool found;
-    double cpt=0;
-
-    P.push_back(val);
-    for(uint i=0;i<P.size();i++){
-        tie(neighbourIt, neighbourEnd) = adjacent_vertices(P[i], g);
-        for (; neighbourIt != neighbourEnd; ++neighbourIt){
-            tie(e1,found)=edge(vertex(P[i],g),vertex(*neighbourIt,g),g);
-            if(In_tab(P,*neighbourIt)!=1){
-                cpt+=g[e1]._weight;
-            }
-        }
-    }
-    return cpt;
-}
-
-
-int In_community_dichotomie(const EntiersEntiers &part, int val)
-{
-    for (uint i = 0; i < part.size() ; i++) {
-        if (In_tab_dichotomie(*part[i], val)) {
-            return i;
-        }
-    }
-    return -1;
-}
-
-double Degree(UnorientedGraph& g, int node)
-{
-    edge_t e1;
-    bool found;
-    double val = 0.;
-
-    tie(neighbourIt, neighbourEnd) = adjacent_vertices(node, g);
-    for (; neighbourIt != neighbourEnd; ++neighbourIt) {
-        tie(e1, found) = edge(vertex(node, g), vertex(*neighbourIt, g), g);
-        val += g[e1]._weight;
-    }
-    return val;
-}
-
-double Cluster_Degree(UnorientedGraph &g , const Entiers &cluster)
-{
-    double val = 0.;
-
-    for(uint i = 0; i < cluster.size(); i++){
-        val += Degree(g, cluster.at(i));
-    }
-    return val;
-}
-
-double Cluster_Weight(UnorientedGraph &g , const Entiers &cluster)
-{
-    double val = 0.;
-
-    for(uint i = 0; i < cluster.size(); i++){
-        val += g[cluster.at(i)]._weight;;
-    }
-    return val;
-}
-
-void List_edge_partie(Entiers *Partie, OrientedGraph *go, Edges &edge_partie,
-                      OutputEdges &outputedgespartie){
-    edge_to e1;
-    //bool found;
-
-    for(uint i = 0; i < Partie->size(); i++) {
-        tie(neighbourIto, neighbourEndo) = adjacent_vertices(Partie->at(i),
-                                                             *go);
-        for (; neighbourIto != neighbourEndo; ++neighbourIto) {
-            if(In_tab_dichotomie(*Partie,*neighbourIto)) {
-                Edge new_edge;
-
-                new_edge.first = Partie->at(i);
-                new_edge.second = *neighbourIto;
-                edge_partie.push_back(new_edge);
-            } else {
-                Edge new_edge;
-
-                new_edge.first = Partie->at(i);
-                new_edge.second = *neighbourIto;
-                outputedgespartie.push_back(new_edge);
-            }
-        }
-    }
-}
-
-void Global_Neigh_community(UnorientedGraph *g,
-                            const EntiersEntiers &Partition,
-                            Entiers *community, int vertex, int comm_in)
-{
-    int comm;
-
-    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex, *g);
-    for (; neighbourIt != neighbourEnd; ++neighbourIt){
-        comm = In_community_dichotomie(Partition, *neighbourIt);
-        if (In_tab(*community,comm) != 1 and comm != comm_in)
-            community->push_back(comm);
-    }
-}
-
-OrientedGraphs Graph_Partition(const EntiersEntiers& Partition,
-                               OrientedGraph *go,
-                               UnorientedGraph *g,
-                               OutputEdgeList &outputedgelist,
-                               InputEdgeList &inputedgelist,
-                               Connections &connections)
-{
-    OrientedGraphs graph_partie;
-    EntiersEntiers neigh_community;
-
-    for (uint i = 0; i < Partition.size();i++){
-        Edges edge_partie;
-        List_edge_partie(Partition.at(i),go,edge_partie,outputedgelist.at(i));
-        OrientedGraph graph;
-        std::vector<vertex_to> tab_vertex_to;
-        Entiers *community = new Entiers();
-
-        for (uint j = 0; j < Partition.at(i)->size(); j++) {
-            Global_Neigh_community(g, Partition, community,
-                                   Partition.at(i)->at(j),i);
-            vertex_to v = add_vertex(graph);
-
-            tab_vertex_to.push_back(v);
-            graph[v] = VertexProperties((*go)[Partition.at(i)->at(j)]._index,
-                                        (*go)[Partition.at(i)->at(j)]._weight,
-                                        (*go)[Partition.at(i)->at(j)]._type);
-        }
-        neigh_community.push_back(community);
-
-        for(uint k = 0; k < edge_partie.size(); k++) {
-            add_edge(tab_vertex_to.at(recherche_val(*Partition.at(i),
-                                                    edge_partie.at(k).first)),
-                     tab_vertex_to.at(recherche_val(*Partition.at(i),
-                                                    edge_partie.at(k).second)),
-                     graph);
-        }
-        graph_partie.push_back(graph);
-    }
-
-    for (uint i = 0; i < neigh_community.size(); i++) {
-        InputEdges inputedges;
-
-        for (uint j = 0; j < neigh_community.at(i)->size(); j++) {
-            for (uint k = 0;
-                 k < outputedgelist.at(neigh_community.at(i)->at(j)).size();
-                 k++) {
-                if (In_tab_dichotomie(
-                        *Partition.at(i),
-                        outputedgelist.at(
-                            neigh_community.at(i)->at(j)).at(k).second))
-                    inputedges.push_back(
-                        outputedgelist.at(
-                            neigh_community.at(i)->at(j)).at(k));
-            }
-        }
-        inputedgelist.push_back(inputedges);
-    }
-
-    for (uint i = 0; i < outputedgelist.size(); i++){
-        Connection connec;
-
-        for(uint j = 0; j < outputedgelist.at(i).size(); j++){
-            Port port1;
-
-            port1.first = i + 1;
-            port1.second = outputedgelist.at(i).at(j).first;
-
-            Port port2;
-
-            port2.first = In_community_dichotomie(
-                Partition,outputedgelist.at(i).at(j).second) + 1;
-            port2.second = outputedgelist.at(i).at(j).second;
-
-            connec.first = port1;
-            connec.second = port2;
-
-            connections.push_back(connec);
-        }
-    }
-
-    for (EntiersEntiers::iterator it = neigh_community.begin();
-        it != neigh_community.end(); it++) {
-        delete *it;
-        *it = NULL;
-    }
-
-    return graph_partie;
-}
-
-double Best_Cut_cluster(EntiersEntiers &tab_cluster,Entiers *cluster1, Entiers *cluster2, int index_cluster1, UnorientedGraph &g,std::string name)
-{
-	tab_cluster.push_back(cluster2);
-
-	double cpt=0.;
-	for(int i=0;i<tab_cluster.size();i++){
-		if(i!=index_cluster1){
-		cpt+=Cut_one_cluster(*tab_cluster[i],g,name);
-		}
-	}
-	cpt+=Cut_one_cluster(*cluster1,g,name);
-	tab_cluster.pop_back();
-	return cpt;
-}
-
-double In_modularity(UnorientedGraph *g , const Entiers &cluster){
-	//property_map<UnorientedGraph,edge_weight_t>::type poids_arc=get(edge_weight_t(),g);
-	edge_t e1;
-	bool found;
-	int val=0;
-
-	for(uint i=0;i<cluster.size();i++){
-		tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i),*g);
-		for (; neighbourIt != neighbourEnd; ++neighbourIt){
-			tie(e1,found)=edge(vertex(cluster[i],*g),vertex(*neighbourIt,*g),*g);
-			if(In_tab(cluster,*neighbourIt)==1)
-				val+=(*g)[e1]._weight;
-				//val+=get(poids_arc,e1);
-		}
-	}
-	return val/2.;
-}
-
-/**
- *
- * @param g
- * @param cluster
- * @return
- */
-
-
-
-/**
- *
- * @param g
- * @param part
- * @return
- */
-
-double Modularity(UnorientedGraph *g,const EntiersEntiers &part){
-  double q  = 0.;
-  int tmp=num_edges(*g);
-  for(uint i=0;i<part.size();i++){
-	  q+=In_modularity(g,*part.at(i))/tmp-(Cluster_Degree(*g,*part.at(i))/(2*tmp))*(Cluster_Degree(*g,*part.at(i))/(2*tmp));
-  	}
-
-  return q;
-}
-
-/**
- *
- * @param part
- * @param val
- * @return
- */
-
-
-
-/**
- * Fonction de calcul du gain de modularité de déplacement d'un sommet d'une communoté à une autre !!!!!
- *  ajoute le sommet à part[val] et on calcul la nouvelle modularité
- *  on prend la différence entre la modularité et la nouvouvelle !
- * @param cur_mod
- * @param val
- * @param neight
- * @param node_comm
- * @param part
- * @param g
- */
-/*double Modularity_gain(double cur_mod , int val , int neight , int node_comm , EntiersEntiers part , UnorientedGraph &g) {
-	double q;
-	part[neight]->push_back(val);
-	std::sort(*part[neight]);
-	q=Modularity(g,part);
-
-	return q-cur_mod;
-}*/
-
-/**
- * Fonction de calcul du gain de modularité de déplacement d'un sommet d'une communoté à une autre !!!!!
- *  ajoute le sommet à part[val] et on calcul la nouvelle modularité
- *  on prend la différence entre la modularité et la nouvouvelle !
- * @param cur_mod
- * @param tmp_community
- * @param neight
- * @param node_comm
- * @param part
- * @param g
- */
-/*double Modularity_gain_phase_2(double cur_mod, Entiers tmp_community, int neight, int node_comm, EntiersEntiers part, UnorientedGraph &g) {
-	double q;
-	for (uint i=0;i<tmp_community.size();i++)
-		part[neight]->push_back(tmp_community[i]);
-	std::sort(*part[neight]);
-	q = Modularity(g,part);
-	return q - cur_mod;
-}*/
-
-/**
- * Donne la liste des communautés voisines à celle contenant le sommet val.
- * @param part
- * @param val
- * @param g
- * @return
- */
-/*Entiers Neight_community(const EntiersEntiers &part, int val , UnorientedGraph &g){
-	Entiers Neight;
-	tie(neighbourIt, neighbourEnd) = adjacent_vertices(val, g);
-	for (; neighbourIt != neighbourEnd; ++neighbourIt){
-		int tmp=In_community(part,*neighbourIt);
-		if(In_tab(Neight,tmp)!=1 && In_tab(*part[In_community(part,val)],*neighbourIt)!=1)
-			Neight.push_back(tmp);
-	}
-	std::sort(Neight);
-	return Neight;
-}*/
-
-/**
- *
- * @param part
- * @param community
- * @param g
- * @return
- */
-/*Entiers Part_Neight_community(const EntiersEntiers &part,int community, UnorientedGraph &g){
-	Entiers Neight;
-	for(uint i =0;i<part[community]->size();i++){
-		tie(neighbourIt, neighbourEnd) = adjacent_vertices(part[community]->at(i), g);
-		for (; neighbourIt != neighbourEnd; ++neighbourIt){
-			int tmp=In_community(part,*neighbourIt);
-			if(In_tab(Neight,tmp)!=1 && tmp!=community)
-				Neight.push_back(tmp);
-		}
-	}
-	std::sort(Neight);
-	return Neight;
-}*/
-
-void make_unoriented_graph(const OrientedGraph& og, UnorientedGraph& ug)
-{
-    std::vector < vertex_t > ug_vertex_list;
-    std::vector < vertex_t > og_vertex_list;
-
-    for (uint i = 0; i < num_vertices(og); ++i) {
-        ug_vertex_list.push_back(add_vertex(ug));
-    }
-
-    OrientedGraph::vertex_iterator it_og, end_og;
-    UnorientedGraph::vertex_iterator it_ug, end_ug;
-
-    tie(it_og, end_og) = vertices(og);
-    tie(it_ug, end_ug) = vertices(ug);
-    for (; it_og != end_og; ++it_og, ++it_ug) {
-        ug[*it_ug] = og[*it_og];
-        og_vertex_list.push_back(*it_og);
-    }
-
-    OrientedGraph::edge_iterator ite_og, ende_og;
-
-    tie(ite_og, ende_og) = edges(og);
-    for (; ite_og != ende_og; ++ite_og) {
-        boost::add_edge(source(*ite_og, og), target(*ite_og, og),
-                        og[*ite_og], ug);
-    }
-
-    // std::cout << "Oriented graph: " << std::endl;
-    // tie(it_og, end_og) = vertices(og);
-    // for (; it_og != end_og; ++it_og) {
-    //     OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
-
-    //     std::cout << og[*it_og]._index << " is connected with ";
-    //     tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_og, og);
-    //     for (; neighbour_it != neighbour_end; ++neighbour_it)
-    //         std::cout << og[*neighbour_it]._index << " ";
-    //     std::cout << " and weight = " << og[*it_og]._weight << std::endl;
-    // }
-    // std::cout << std::endl;
-
-    // std::cout << "Unoriented graph: " << std::endl;
-    // tie(it_ug, end_ug) = vertices(ug);
-    // for (; it_ug != end_ug; ++it_ug) {
-    //     UnorientedGraph::adjacency_iterator neighbour_it, neighbour_end;
-
-    //     std::cout << ug[*it_ug]._index << " is connected with ";
-    //     tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_ug, ug);
-    //     for (; neighbour_it != neighbour_end; ++neighbour_it)
-    //         std::cout << ug[*neighbour_it]._index << " ";
-    //     std::cout << " and weight = " << ug[*it_ug]._weight << std::endl;
-    // }
-    // std::cout << std::endl;
-}
-
-void adjacence_ggp(int vertex, Entiers &sommets_adj, UnorientedGraph *g)
-{
-    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex, *g);
-    for (; neighbourIt != neighbourEnd; ++neighbourIt)
-    {
-        sommets_adj.push_back(*neighbourIt);
-    }
-
-}
-
-double modif_Cout_coupe(const Entiers &P, int val, double cut, UnorientedGraph *g)
-{
-    //std::cout<<"Cout de coupe initiale : "<<cut<<std::endl;
-    //std::cout<<"degré du sommet tiré : "<<Degree(*g,val)<<std::endl;
-    double cpt = 0.;
-    double new_cut;
-    bool found;
-	edge_t e1;
-    tie(neighbourIt, neighbourEnd) = adjacent_vertices(val, *g);
-    for (; neighbourIt != neighbourEnd; neighbourIt++){
-        if(In_tab(P,*neighbourIt)==1){
-			tie(e1,found)=edge(vertex(val,*g),vertex(*neighbourIt,*g),*g);
-            cpt += (*g)[e1]._weight;
-        }
-    }
-    new_cut = cut + (Degree(*g,val) - 2*cpt);
-    return new_cut;
-}
-
-int decimal(int valeur){
-	int res;
-	switch(valeur){
-		case 0 ... 9 : res = 0;
-		break;
-		case 10 ... 99 : res = 1;
-		break;
-		case 100 ... 999 : res = 2;
-		break;
-		case 1000 ... 9999 : res = 3;
-		break;
-		case 10000 ... 99999 : res = 4;
-		break;
-		case 100000 ... 999999 : res = 5;
-		break;
-		case 1000000 ... 9999999 : res = 6;
-		break;
-		case 10000000 ... 99999999 : res = 7;
-		break;
-		case 100000000 ... 999999999 : res = 8;
-		break;
-	default :
-		std::cout<<"L'interval n'est pas de taille suffisante"<<std::endl;
-		break;
-	}
-	return res;
-}
-
-void Graph_constructor_txt(const char* text, OrientedGraph * Og){
-
-	//Traitement initial
-	std::ifstream fichier (text, std::ios::in);
-	int lines = std::count(std::istreambuf_iterator<char>( fichier ),
-	std::istreambuf_iterator<char>(),'\n' );
-	//std::cout<<"Nombre de ligne : "<<lines<<std::endl;
-
-	fichier.seekg(0, std::ios::beg);
-	std::string caractere;
-	getline(fichier, caractere);
-	int caractere_size = caractere.size()+1;
-
-	fichier.seekg(0, std::ios::beg);
-	int nbr_vertices;
-	fichier >> nbr_vertices;
-	//std::cout << "Nombre de sommets : "<< nbr_vertices<< std::endl;
-
-	//Création des sommets
-
-	std::vector<vertex_to> vect_vertex;
-	for(int i =0; i<nbr_vertices; i++){
-		vertex_to v0 = boost::add_vertex(*Og);
-		vect_vertex.push_back(v0);
-	}
-
-	//Création des arcs
-	int deplacement_sup = 0;
-	for(int i = 0; i <(lines-nbr_vertices-1); i++){
-	fichier.seekg((8)*i+caractere_size+deplacement_sup, std::ios::beg);
-	int vertex_in, vertex_out;
-	double weight;
-	fichier >> vertex_in >> vertex_out >> weight ;
-	add_edge(vect_vertex.at(vertex_in), vect_vertex.at(vertex_out), EdgeProperties(weight), *Og);
-	//std::cout << vertex_in << " " << vertex_out << " " << weight << std::endl;
-	int tmp = decimal(vertex_in) + decimal(vertex_out) + decimal(floor(weight));
-	deplacement_sup += tmp;
-	}
-
-	//Pondération des sommets
-	int cpt =0;
-	for(int i = lines-nbr_vertices-1; i <lines-1; i++){
-	fichier.seekg((8)*(lines-nbr_vertices-1)+caractere_size+deplacement_sup, std::ios::beg);
-	double poids;
-	std::string txt;
-	fichier >> poids >> txt ;
-	int type;
-	if(txt == "NORMAL_PIXEL"){
-		type = 1;
-		// type = NORMAL_PIXEL;
-	}else{
-		type = 0;
-		// type = TOP_PIXEL;
-	}
-	(*Og)[vect_vertex.at(cpt)] = VertexProperties(cpt, poids, type);
-	//std::cout << poids << std::endl;
-	int tmp = decimal(floor(poids)) + 17;
-	deplacement_sup += tmp;
-	cpt++;
-	}
-
-	fichier.close();
-}
-
-void Text_generator_graph(const char *texte, OrientedGraph *go){
-
-	bool found;
-	edge_to e1;
-	std::ofstream fichier (texte, std::ios::out);
-    fichier<<num_vertices(*go)<<std::endl;
-    tie(vertexIto, vertexEndo) = vertices(*go);
-    for (; vertexIto != vertexEndo; ++vertexIto) {
-    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
-    			*go);
-    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
-			tie(e1,found)=edge(vertex(*vertexIto,*go),vertex(*neighbourIto,*go),*go);
-			if(((*go)[e1]._weight - floor((*go)[e1]._weight)) == 0 ){
-				fichier<<(*go)[*vertexIto]._index<<" "<<(*go)[*neighbourIto]._index<<" "<<(*go)[e1]._weight<<".0"<<std::endl;
-			}else{
-				fichier<<(*go)[*vertexIto]._index<<" "<<(*go)[*neighbourIto]._index<<" "<<(*go)[e1]._weight<<std::endl;
-			}
-    	}
-    }
-    tie(vertexIto, vertexEndo) = vertices(*go);
-    for (; vertexIto != vertexEndo; ++vertexIto) {
-        if(((*go)[*vertexIto]._weight - floor((*go)[*vertexIto]._weight)) == 0 && (*go)[*vertexIto]._type == 0 /*TOP_PIXEL*/){
-			fichier<<(*go)[*vertexIto]._weight<<".0"<<" "<<"TOP_PIXEL"<<"   "<<std::endl;
-		}else if(((*go)[*vertexIto]._weight - floor((*go)[*vertexIto]._weight)) == 0 && (*go)[*vertexIto]._type == 1 /*NORMAL_PIXEL*/){
-			fichier<<(*go)[*vertexIto]._weight<<".0"<<" "<<"NORMAL_PIXEL"<<std::endl;
-		}else if(((*go)[*vertexIto]._weight - floor((*go)[*vertexIto]._weight)) != 0 && (*go)[*vertexIto]._type == 0 /*TOP_PIXEL*/){
-			fichier<<(*go)[*vertexIto]._weight<<" "<<"TOP_PIXEL"<<std::endl;
-		}else{
-			fichier<<(*go)[*vertexIto]._weight<<" "<<"NORMAL_PIXEL"<<std::endl;
-		}
-    }
-
-	fichier.close();
-}
-
-double Diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition, int partie, int node, std::string name){
-	double Dif;
-	double Int = 0.;
-	double Ext = 0.;
-
-	edge_t e1;
-    bool found;
-
-    tie(neighbourIt, neighbourEnd) = adjacent_vertices(node, *g);
-    for (; neighbourIt != neighbourEnd; ++neighbourIt){
-		tie(e1, found) = edge(vertex(node, *g), vertex(*neighbourIt, *g), *g);
-		if(In_tab_dichotomie(*Partition.at(partie),*neighbourIt) == 1){
-			Int+= (*g)[e1]._weight;
-		}else{
-			Ext+= (*g)[e1]._weight;
-		}
-    }
-
-	if(name == "ratio"){
-	    Int/=Cluster_Weight(*g,*Partition.at(partie));
-	    Ext/=Cluster_Weight(*g,*Partition.at(partie));
-	}
-
-	Dif = Ext - Int;
-	return Dif;
-}
-
-double Diff_cut_ratio_bissection(UnorientedGraph *g, Entiers *part, int node, std::string name){
-	double Ext = 0.;
-
-	edge_t e1;
-    bool found;
-
-    tie(neighbourIt, neighbourEnd) = adjacent_vertices(node, *g);
-    for (; neighbourIt != neighbourEnd; ++neighbourIt){
-		tie(e1, found) = edge(vertex(node, *g), vertex(*neighbourIt, *g), *g);
-		if(In_tab_dichotomie(*part,*neighbourIt) != 1){
-			Ext+= (*g)[e1]._weight;
-		}
-    }
-
-	return Ext;
-}
-
-std::vector<std::vector<int>> Vector_diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition, std::string name){
-	std::vector<std::vector<int>> Diff_vector;
-
-	for(uint i = 0; i < Partition.size(); i++){
-		std::vector<std::pair<double,int>> D_vector;
-		for(uint j = 0; j < Partition.at(i)->size(); j++){
-			double gain_d = Diff_cut_ratio(g, Partition, i, Partition.at(i)->at(j), name);
-			//std::cout<<gain_d<<std::endl;
-			if(gain_d > 0){
-				std::pair<double, int> D;
-				D.first =  gain_d;
-				D.second = Partition.at(i)->at(j);
-				D_vector.push_back(D);
-			}
-		}
-		sort(D_vector.begin(),D_vector.end());
-		std::reverse(D_vector.begin(),D_vector.end());
-		std::vector<int> index_vector;
-		for(uint id = 0; id < D_vector.size(); id++){
-			index_vector.push_back(D_vector.at(id).second);
-		}
-		Diff_vector.push_back(index_vector);
-	}
-
-	/*std::cout<<"Tableau des différences "<<std::endl;
-	for(uint i = 0; i<Diff_vector.size(); i++){
-		std::cout<<"*"<<i<<"* ";
-		for(uint j = 0; j<Diff_vector.at(i).size(); j++){
-			std::cout<<Diff_vector.at(i).at(j)<<" ";
-		}
-		std::cout<<std::endl;
-	}*/
-
-	return Diff_vector;
-
-}
-
-std::vector<int> Vector_diff_cut_ratio_2(UnorientedGraph *g, const EntiersEntiers &Partition, std::string name){
-	std::vector<int> Diff_vector;
-	std::vector<std::pair<double,int>> D_vector;
-	for(uint i = 0; i < Partition.size(); i++){
-		for(uint j = 0; j < Partition.at(i)->size(); j++){
-			double gain_d = Diff_cut_ratio(g, Partition, i, Partition.at(i)->at(j), name);
-			//std::cout<<gain_d<<std::endl;
-			if(gain_d > 0){
-				std::pair<double, int> D;
-				D.first =  gain_d;
-				D.second = Partition.at(i)->at(j);
-				D_vector.push_back(D);
-			}
-		}
-	}
-	sort(D_vector.begin(),D_vector.end());
-	for(uint id = 0; id < D_vector.size(); id++){
-		Diff_vector.push_back(D_vector.at(id).second);
-	}
-
-	/*std::cout<<"Tableau des différences "<<std::endl;
-	for(uint i = 0; i<Diff_vector.size(); i++){
-		std::cout<<"*"<<i<<"* ";
-		for(uint j = 0; j<Diff_vector.at(i).size(); j++){
-			std::cout<<Diff_vector.at(i).at(j)<<" ";
-		}
-		std::cout<<std::endl;
-	}*/
-	/*for(uint j = 0; j<Diff_vector.size(); j++){
-		std::cout<<Diff_vector.at(j)<<" ";
-	}
-	std::cout<<std::endl;*/
-
-	return Diff_vector;
-
-}
-
-void Modif_vector_diff_cut_ratio_2(UnorientedGraph *g, const EntiersEntiers &Partition, std::vector<int> &Diff_vector, int node, std::string name){
-	std::vector<std::pair<double,int>> D_vector;
-
-	tie(neighbourIt, neighbourEnd) = adjacent_vertices(node, *g);
-	for (; neighbourIt != neighbourEnd; ++neighbourIt){
-		//std::cout<<"node : "<<node<<std::endl;
-		//std::cout<<"voisin : "<<*neighbourIt<<std::endl;
-		int neigh_ind = In_community_dichotomie(Partition, *neighbourIt);
-		//std::cout<<"dans  : "<<neigh_ind<<std::endl;
-		double gain_d = Diff_cut_ratio(g, Partition, neigh_ind, *neighbourIt, name);
-		//std::cout<<"gain_d : "<<gain_d<<std::endl;
-		if(gain_d > 0){
-			std::pair<double, int> D;
-			D.first =  gain_d;
-			D.second = *neighbourIt;
-			D_vector.push_back(D);
-		}
-		//suprim_val(Diff_vector,*neighbourIt);
-	}
-
-	if(D_vector.size() == 0){
-		Diff_vector.erase(Diff_vector.begin());
-		return;
-	}
-
-	//std::cout<<"**"<<std::endl;
-	sort(D_vector.begin(),D_vector.end());
-	for(uint id = 0; id < D_vector.size(); id++){
-		if(In_tab(Diff_vector,D_vector.at(id).second) != 1)
-			Diff_vector.push_back(D_vector.at(id).second);
-	}
-	//std::cout<<"***"<<std::endl;
-	Diff_vector.erase(Diff_vector.begin());
-	//std::cout<<"**!**"<<std::endl;
-
-	sort(Diff_vector.begin(),Diff_vector.end());
-
-	for(uint j = 0; j<Diff_vector.size(); j++){
-		std::cout<<Diff_vector.at(j)<<" ";
-	}
-	//std::cout<<std::endl;
-}
-
-void Modif_vector_diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition, std::vector<std::vector<int>> &Diff_vector, int recalcul1, int recalcul2, std::string name){
-
-	std::vector<std::pair<double,int>> D_vector;
-	for(uint j = 0; j < Partition.at(recalcul1)->size(); j++){
-		double gain_d = Diff_cut_ratio(g, Partition, recalcul1, Partition.at(recalcul1)->at(j), name);
-		//std::cout<<gain_d<<std::endl;
-		if(gain_d > 0){
-			std::pair<double, int> D;
-			D.first =  gain_d;
-			D.second = Partition.at(recalcul1)->at(j);
-			D_vector.push_back(D);
-		}
-	}
-	sort(D_vector.begin(),D_vector.end());
-	std::reverse(D_vector.begin(),D_vector.end());
-	std::vector<int> index_vector;
-	for(uint id = 0; id < D_vector.size(); id++){
-		index_vector.push_back(D_vector.at(id).second);
-	}
-	Diff_vector.at(recalcul1) = index_vector;
-
-	std::vector<std::pair<double,int>> D_vector2;
-	for(uint j = 0; j < Partition.at(recalcul2)->size(); j++){
-		double gain_d = Diff_cut_ratio(g, Partition, recalcul2, Partition.at(recalcul2)->at(j), name);
-		//std::cout<<gain_d<<std::endl;
-		if(gain_d > 0){
-			std::pair<double, int> D;
-			D.first =  gain_d;
-			D.second = Partition.at(recalcul2)->at(j);
-			D_vector2.push_back(D);
-		}
-	}
-	sort(D_vector2.begin(),D_vector2.end());
-	std::reverse(D_vector2.begin(),D_vector2.end());
-	std::vector<int> index_vector2;
-	for(uint id = 0; id < D_vector2.size(); id++){
-		index_vector2.push_back(D_vector2.at(id).second);
-	}
-	Diff_vector.at(recalcul2) = index_vector2;
-
-	/*std::cout<<"Tableau des différences modifié "<<std::endl;
-	for(uint i = 0; i<Diff_vector.size(); i++){
-		std::cout<<"*"<<i<<"* ";
-		for(uint j = 0; j<Diff_vector.at(i).size(); j++){
-			std::cout<<Diff_vector.at(i).at(j)<<" ";
-		}
-		std::cout<<std::endl;
-	}*/
-
-}
-
-void Affinache_gain_diff(UnorientedGraph *g, EntiersEntiers &Partition, double &cut, std::string name, double poids_moy){
-	double old_cut = -1.;
-
-	while(old_cut != cut){
-		//std::cout<<"Boucle d'ammélioration "<<std::endl;
-		old_cut = cut;
-		sort(Partition.begin(), Partition.end(), myobject_taille);
-		/*for(uint i=0;i<Partition.size();i++){
-			std::cout<<Partition.at(i)->size()<<std::endl;
-		}*/
-		std::vector<std::vector<int>> diff_vector;
-		diff_vector = Vector_diff_cut_ratio(g, Partition, name);
-
-		/*for(uint i = 0; i<diff_vector.size(); i++){
-			std::cout<<diff_vector.at(i)<<std::endl;
-		}*/
-
-		for(uint indice = 0; indice < diff_vector.size(); indice ++){
-			if(diff_vector.at(indice).size() != 0 && Partition.at(indice)->size() >1){
-				//for(uint i = 0; i < diff_vector.at(indice).size(); i++){
-				int i =0;
-				while(diff_vector.at(indice).size() != 0 && Partition.at(indice)->size() >1 && i < diff_vector.at(indice).size() &&
-				Cluster_Weight(*g,*Partition.at(indice)) > (poids_moy-poids_moy/Partition.size())){
-					//std::cout<<"Sommet de départ : "<< (*g)[diff_vector.at(indice).at(i)]._index <<" dans "<<indice<<std::endl;
-					Entiers neigh_part;
-					neigh_part = Neigh_community(g, Partition, diff_vector.at(indice).at(i), indice);
-					int best_neigh_part = neigh_part.at(0);
-					double gain = -10000000.;
-					for(uint ind_neigh = 0; ind_neigh < neigh_part.size(); ind_neigh++){
-						double tmp_gain;
-						if(name == "ratio"){
-							tmp_gain = Gain_ratio(g,Partition,indice,neigh_part.at(ind_neigh),diff_vector.at(indice).at(i),cut);
-						}else{
-							double Int = 0.;
-							double Ext = 0.;
-							edge_t e1;
-						    bool found;
-
-						    tie(neighbourIt, neighbourEnd) = adjacent_vertices(diff_vector.at(indice).at(i), *g);
-						    for (; neighbourIt != neighbourEnd; ++neighbourIt){
-								tie(e1, found) = edge(vertex(diff_vector.at(indice).at(i), *g), vertex(*neighbourIt, *g), *g);
-								if(In_tab_dichotomie(*Partition.at(neigh_part.at(ind_neigh)),*neighbourIt) == 1){
-									Ext+= (*g)[e1]._weight;
-								}else if(In_tab_dichotomie(*Partition.at(indice),*neighbourIt) == 1){
-									Int+= (*g)[e1]._weight;
-								}
-						    }
-								tmp_gain = Ext - Int;
-						}
-
-					    if(tmp_gain > gain & tmp_gain > 0){
-							gain = tmp_gain;
-							best_neigh_part = neigh_part.at(ind_neigh);
-						}
-					}
-
-					//std::cout<<" Ensemble de déstination "<<best_neigh_part<<" gain de  : "<<gain<<std::endl;
-					if(gain > 0){
-						//std::cout<<"Modification"<<std::endl;
-						cut -= gain; /*Grosse modification a apporté de ce coté la*/
-						//std::cout<<"Ratio de coupe : "<<cut<<std::endl;
-						suprim_val(*Partition.at(indice),diff_vector.at(indice).at(i));
-						Partition.at(best_neigh_part)->push_back(diff_vector.at(indice).at(i));
-						sort(Partition.at(best_neigh_part)->begin(),Partition.at(best_neigh_part)->end());
-						//double cut2 = Cut_cluster(Partition,*g,"ratio");
-						//std::cout<<"Vrai ratio de coupe : "<<cut2<<std::endl;
-						Modif_vector_diff_cut_ratio(g,Partition,diff_vector,best_neigh_part,indice,name);
-						i = 0;
-					}else{
-						i++;
-					}
-				}
-			}
-		}
-		//std::cout<<cut<<std::endl;
-	}
-}
-
-void Affinache_gain_diff_2(UnorientedGraph *g, EntiersEntiers &Partition, double &cut, std::string name, double poids_moy){
-	double old_cut = -1.;
-
-	//while(old_cut != cut){
-		//std::cout<<"Boucle d'ammélioration "<<std::endl;
-		//old_cut = cut;
-		sort(Partition.begin(), Partition.end(), myobject_taille);
-		std::vector<int> diff_vector;
-		diff_vector = Vector_diff_cut_ratio_2(g, Partition, name);
-
-		//for(uint indice = 0; indice < diff_vector.size(); indice ++){
-		int indice = 0;
-		while(/*indice < diff_vector.size() &&*/ diff_vector.size() != 0){
-			int com = In_community_dichotomie(Partition,diff_vector.at(indice));
-			std::cout<<" Ensemble de départ "<<com<<" sommet  : "<<diff_vector.at(indice)<<std::endl;
-			if(Partition.at(com)->size() >1 && Cluster_Weight(*g,*Partition.at(com)) > (poids_moy-poids_moy/Partition.size())){
-				Entiers neigh_part;
-				neigh_part = Neigh_community(g, Partition, diff_vector.at(indice), com);
-				int best_neigh_part = neigh_part.at(0);
-				double gain = -10000000.;
-				for(uint ind_neigh = 0; ind_neigh < neigh_part.size(); ind_neigh++){
-					double tmp_gain;
-					if(name == "ratio"){
-						tmp_gain = Gain_ratio(g,Partition,com,neigh_part.at(ind_neigh),diff_vector.at(indice),cut);
-					}else{
-						double Int = 0.;
-						double Ext = 0.;
-						edge_t e1;
-					    bool found;
-
-					    tie(neighbourIt, neighbourEnd) = adjacent_vertices(diff_vector.at(indice), *g);
-					    for (; neighbourIt != neighbourEnd; ++neighbourIt){
-							tie(e1, found) = edge(vertex(diff_vector.at(indice), *g), vertex(*neighbourIt, *g), *g);
-							if(In_tab_dichotomie(*Partition.at(neigh_part.at(ind_neigh)),*neighbourIt) == 1){
-								Ext+= (*g)[e1]._weight;
-							}else if(In_tab_dichotomie(*Partition.at(com),*neighbourIt) == 1){
-								Int+= (*g)[e1]._weight;
-							}
-					    }
-							tmp_gain = Ext - Int;
-					}
-
-				    if(tmp_gain > gain & tmp_gain > 0){
-						gain = tmp_gain;
-						best_neigh_part = neigh_part.at(ind_neigh);
-					}
-				}
-
-				std::cout<<" Ensemble de déstination "<<best_neigh_part<<" gain de  : "<<gain<<std::endl;
-				if(gain > 0){
-					std::cout<<"Modification"<<std::endl;
-					cut -= gain; /*Grosse modification a apporté de ce coté la*/
-					std::cout<<"Ratio de coupe : "<<cut<<std::endl;
-					suprim_val(*Partition.at(com),diff_vector.at(indice));
-					Partition.at(best_neigh_part)->push_back(diff_vector.at(indice));
-					sort(Partition.at(best_neigh_part)->begin(),Partition.at(best_neigh_part)->end());
-					double cut2 = Cut_cluster(Partition,*g,"ratio");
-					std::cout<<"Vrai ratio de coupe : "<<cut2<<std::endl;
-					//Modif_vector_diff_cut_ratio_2(g,Partition,diff_vector,diff_vector.at(indice),name);
-					//indice = 0;
-					diff_vector.erase(diff_vector.begin());
-				}else{
-					diff_vector.erase(diff_vector.begin());
-				}
-			}
-		}
-		//std::cout<<cut<<std::endl;
-//	}
-}
-
-double Gain_ratio(UnorientedGraph *g,const EntiersEntiers &Partition, int in, int out, int node, double ratio){
-	double new_ratio = ratio;
-	double poids_in = Cluster_Weight(*g,*Partition.at(in));
-	double poids_out = Cluster_Weight(*g,*Partition.at(out));
-	double tmp_poids_in = poids_in - (*g)[node]._weight;
-	double tmp_poids_out = poids_out + (*g)[node]._weight;
-	//std::cout<<"tmp_poids_in "<< tmp_poids_in <<std::endl;
-	//std::cout<<"tmp_poids_out "<< tmp_poids_out <<std::endl;
-
-	double cut_in = 0.;
-	double cut_out = 0.;
-	double tmp_cut_in = 0.;
-	double tmp_cut_out = 0.;
-
-	edge_t e1;
-	bool found;
-
-	for(uint i = 0; i < Partition.at(in)->size(); i++){
-		tie(neighbourIt, neighbourEnd) = adjacent_vertices(Partition.at(in)->at(i), *g);
-		for (; neighbourIt != neighbourEnd; ++neighbourIt){
-			tie(e1,found)=edge(vertex(Partition.at(in)->at(i),*g),vertex(*neighbourIt,*g),*g);
-			if(In_tab_dichotomie(*Partition.at(in),*neighbourIt) != 1){
-				if(Partition.at(in)->at(i) != node){
-					tmp_cut_in += (*g)[e1]._weight;
-				}
-				cut_in += (*g)[e1]._weight;
-			}else if(*neighbourIt == node){
-				tmp_cut_in += (*g)[e1]._weight;
-			}
-		}
-	}
-
-	for(uint i = 0; i < Partition.at(out)->size(); i++){
-		tie(neighbourIt, neighbourEnd) = adjacent_vertices(Partition.at(out)->at(i), *g);
-		for (; neighbourIt != neighbourEnd; ++neighbourIt){
-			tie(e1,found)=edge(vertex(Partition.at(out)->at(i),*g),vertex(*neighbourIt,*g),*g);
-			if(In_tab_dichotomie(*Partition.at(out),*neighbourIt) != 1){
-				if(*neighbourIt != node){
-					tmp_cut_out += (*g)[e1]._weight;
-				}
-				cut_out += (*g)[e1]._weight;
-			}
-		}
-	}
-	tie(neighbourIt, neighbourEnd) = adjacent_vertices(node, *g);
-	for (; neighbourIt != neighbourEnd; ++neighbourIt){
-		tie(e1,found)=edge(vertex(node,*g),vertex(*neighbourIt,*g),*g);
-		if(In_tab_dichotomie(*Partition.at(out),*neighbourIt) != 1){
-			tmp_cut_out += (*g)[e1]._weight;
-		}
-	}
-
-	//std::cout<<"tmp_cut_in "<< tmp_cut_in/2. <<std::endl;
-	//std::cout<<"tmp_cut_out "<< tmp_cut_out/2. <<std::endl;
-	new_ratio -= cut_in/2./poids_in;
-	new_ratio -= cut_out/2./poids_out;
-	new_ratio += tmp_cut_in/2./tmp_poids_in;
-	new_ratio += tmp_cut_out/2./tmp_poids_out;
-
-	//std::cout<<"Nouveau ratio : " <<new_ratio<<std::endl;
-	return ratio - new_ratio;
-
-}
-
-double Modif_ratio_cut(UnorientedGraph *g,Entiers *Ss, Entiers *Sd, int node, double ratio){/*Revoir cette fonction, modification psa forcement nécéssaire, plus simple !!!*/
-	double new_ratio;
-	double poids_in = Cluster_Weight(*g,*Ss);
-	double poids_out = Cluster_Weight(*g,*Sd);
-	double tmp_poids_in = poids_in - (*g)[node]._weight;
-	double tmp_poids_out = poids_out + (*g)[node]._weight;
-	//std::cout<<"tmp_poids_in "<< tmp_poids_in <<std::endl;
-	//std::cout<<"tmp_poids_out "<< tmp_poids_out <<std::endl;
-
-	double new_cut = 0.;
-	//double new_cut_out = 0.;
-	//double tmp_cut_in = 0.;
-	//double tmp_cut_out = 0.;
-
-	edge_t e1;
-	bool found;
-
-	for(uint i = 0; i < Ss->size(); i++){
-		if(Ss->at(i) != node){
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(Ss->at(i), *g);
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-				tie(e1,found)=edge(vertex(Ss->at(i),*g),vertex(*neighbourIt,*g),*g);
-				if(In_tab_dichotomie(*Ss,*neighbourIt) != 1){
-					new_cut += (*g)[e1]._weight;
-				}else if(*neighbourIt == node){
-					new_cut += (*g)[e1]._weight;
-				}
-			}
-		}
-	}
-
-	/*for(uint i = 0; i < Sd->size(); i++){
-		tie(neighbourIt, neighbourEnd) = adjacent_vertices(Sd->at(i), *g);
-		for (; neighbourIt != neighbourEnd; ++neighbourIt){
-			tie(e1,found)=edge(vertex(Sd->at(i),*g),vertex(*neighbourIt,*g),*g);
-			if(In_tab(*Sd,*neighbourIt) != 1){
-				if(*neighbourIt != node){
-					tmp_cut_out += (*g)[e1]._weight;
-				}
-				cut_out += (*g)[e1]._weight;
-			}
-		}
-	}
-	tie(neighbourIt, neighbourEnd) = adjacent_vertices(node, *g);
-	for (; neighbourIt != neighbourEnd; ++neighbourIt){
-		tie(e1,found)=edge(vertex(node,*g),vertex(*neighbourIt,*g),*g);
-		if(In_tab(*Sd,*neighbourIt) != 1){
-			tmp_cut_out += (*g)[e1]._weight;
-		}
-	}*/
-
-	//std::cout<<"tmp_cut_in "<< tmp_cut_in/2. <<std::endl;
-	//std::cout<<"tmp_cut_out "<< tmp_cut_out/2. <<std::endl;
-	new_ratio = new_cut/2./tmp_poids_in + new_cut/2./tmp_poids_out;
-	/*new_ratio -= cut_out/2./poids_out;
-	new_ratio += tmp_cut_in/2./tmp_poids_in;
-	new_ratio += tmp_cut_out/2./tmp_poids_out;*/
-
-	//std::cout<<"Nouveau ratio : " <<new_ratio<<std::endl;
-	return new_ratio;
-}
-
-EntiersEntiers Spectral_Partition(const char* text){
-	//Traitement initial
-	EntiersEntiers Partition;
-	std::ifstream fichier (text, std::ios::in);
-	if(fichier){
-		int lines = std::count(std::istreambuf_iterator<char>( fichier ),
-		std::istreambuf_iterator<char>(),'\n' );
-		std::cout<<"Nombre de ligne : "<<lines<<std::endl;
-		/*** Récupération du dernier caractère ***/
-
-		/*** Création des paramétres contenant les informations ***/
-
-		int nmax_vertex;
-		fichier.seekg(0, std::ios::beg);
-		fichier >> nmax_vertex;
-		std::cout<<"nmax_vertex : "<<nmax_vertex<<std::endl;
-		int nmax_size = decimal(nmax_vertex) + 1;
-
-		/*** Récupération des informations ***/
-		int cpt = 1;
-		int length;
-		fichier.seekg(nmax_size, std::ios::beg);
-		while(cpt < lines){
-		Entiers *part = new Entiers();
-		for(uint i =0; i<nmax_vertex; i++){
-		 	int edge;
-			fichier >> edge;
-			if(edge != -1)
-				part->push_back(edge);
-		}
-		Partition.push_back(part);
-		length = fichier.tellg();
-		fichier.seekg(length+1, std::ios::beg);
-		cpt++;
-		}
-	}else{
-		std::cerr << "Impossible d'ouvrir le fichier dans Spectral_Partition !" << std::endl;
-	}
-
-	return(Partition);
-}
-
-void Adjacent_Matrix_Txt(UnorientedGraph *g, const char* text){
-	std::ofstream GRAPH4 (text, std::ios::out);
-	if(GRAPH4){
-		tie(vertexIt, vertexEnd) = vertices(*g);
-		edge_t e1;
-		bool found;
-
-		for (; vertexIt != vertexEnd; ++vertexIt) {
-			int cpt = 0;
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
-			*g);
-			for(int i = cpt; i<num_vertices(*g); i++){
-				if(i == *neighbourIt){
-					tie(e1,found)=edge(vertex(*vertexIt,*g),vertex(*neighbourIt,*g),*g);
-					GRAPH4<<(*g)[e1]._weight<<" ";
-					cpt = *neighbourIt +1;
-					++neighbourIt;
-					if(*neighbourIt == *neighbourEnd){
-						for(int j = cpt; j<num_vertices(*g); j++)
-							GRAPH4<<0<<" ";
-						break;
-					}
-				}else{
-					GRAPH4<<0<<" ";
-				}
-			}
-			GRAPH4<<std::endl;
-		}
-
-		GRAPH4.close();
-	}else
-		 std::cerr << "Impossible d'ouvrir le fichier dans Adjacent_Matrix_Txt !" << std::endl;
-}
-
-void Weight_Matrix_Txt(UnorientedGraph *g, const char* text){
-	std::ofstream GRAPH4 (text, std::ios::out);
-	if(GRAPH4){
-		for (int i =0 ; i<num_vertices(*g); i++) {
-			GRAPH4<<(*g)[i]._weight<<" ";
-		}
-
-		GRAPH4.close();
-	}else
-		 std::cerr << "Impossible d'ouvrir le fichier dans Weight_Matrix_Txt !" << std::endl;
-}
-
-void Plot_OrientedGraph(OrientedGraph *go, const char* text){
-	edge_to e1;
-	bool found;
-
-	std::ofstream fichier2 (text, std::ios::out);
-    fichier2<<"digraph G {"<<std::endl;
-    tie(vertexIto, vertexEndo) = vertices(*go);
-    for (; vertexIto != vertexEndo; ++vertexIto) {
-    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
-    			*go);
-    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
-    		tie(e1,found)=edge(vertex(*vertexIto,*go),
-							   vertex(*neighbourIto,*go),*go);
-			fichier2<<(*go)[*vertexIto]._index<<" -> "
-					<<(*go)[*neighbourIto]._index<<" [label="
-					<<(*go)[e1]._weight
-					<<", fontsize=10, fontcolor= blue];"<<std::endl;
-    	}
-	}
-
-	fichier2<<"}";
-	fichier2.close();
-
-}
-
-void Plot_UnorientedGraph(UnorientedGraph *g, const char* text){
-	edge_t e1;
-	bool found;
-
-	std::ofstream GRAPH2 (text, std::ios::out);
-	GRAPH2<<"graph G {"<<std::endl;
-	tie(vertexIt, vertexEnd) = vertices(*g);
-	for (; vertexIt != vertexEnd; ++vertexIt) {
-		tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,*g);
-		for (; neighbourIt != neighbourEnd; ++neighbourIt){
-			if((*g)[*neighbourIt]._index>(*g)[*vertexIt]._index){
-				tie(e1,found)=edge(vertex(*vertexIt,*g),vertex(*neighbourIt,*g),*g);
-				GRAPH2<<(*g)[*vertexIt]._index<<" -- "<<(*g)[*neighbourIt]._index<<" [label="<<(*g)[e1]._weight<<", fontsize=10, fontcolor= blue];"<<std::endl;
-			}
-		}
-	}
-
-	GRAPH2<<"}";
-	GRAPH2.close();
-}
-
-void Plot_UnorientedGraph_All(UnorientedGraph *g, const EntiersEntiers &Partition, const char* text, bool Color){
-	edge_t e1;
-	bool found;
-
-	if(Partition.size()<17){
-		std::ofstream GRAPH2 (text, std::ios::out);
-		GRAPH2<<"graph G {"<<std::endl;
-		tie(vertexIt, vertexEnd) = vertices(*g);
-		for (; vertexIt != vertexEnd; ++vertexIt) {
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,*g);
-			for (; neighbourIt != neighbourEnd; ++neighbourIt){
-				if((*g)[*neighbourIt]._index>(*g)[*vertexIt]._index){
-					tie(e1,found)=edge(vertex(*vertexIt,*g),vertex(*neighbourIt,*g),*g);
-					GRAPH2<<(*g)[*vertexIt]._index<<" -- "<<(*g)[*neighbourIt]._index<<" [label="<<(*g)[e1]._weight<<", fontsize=10, fontcolor= blue];"<<std::endl;}
-			}
-		}
-
-		if(Color == true){
-			std::vector<std::string> color;
-			color.push_back(", color=blue2, fontcolor=blue2];");
-			color.push_back(", color=red, fontcolor=red];");
-			color.push_back(", color=green, fontcolor=green];");
-			color.push_back(", color=turquoise, fontcolor=turquoise];");
-			color.push_back(", color=saddlebrown, fontcolor=saddlebrown];");
-			color.push_back(", color=indigo, fontcolor=indigo];");
-			color.push_back(", color=yellow, fontcolor=yellow2];");
-			color.push_back(", color=orange, fontcolor=orange];");
-			color.push_back(", color=olivedrab, fontcolor=olivedrab];");
-			color.push_back(", color=gold, fontcolor=gold];");
-			color.push_back(", color=slateblue2, fontcolor=slateblue2];");
-			color.push_back(", color=dimgrey, fontcolor=dimgrey];");
-			color.push_back(", color=cyan, fontcolor=cyan];");
-			color.push_back(", color=purple1, fontcolor=purpule1];");
-			color.push_back(", color=crimson, fontcolor=crimson];");
-			color.push_back(", color=black, fontcolor=black];");
-			for(uint k=0; k<Partition.size(); k++){
-				for(uint t=0; t<Partition.at(k)->size(); t++)
-				{
-					GRAPH2<<(*g)[Partition.at(k)->at(t)]._index<<" [label="<<(*g)[Partition.at(k)->at(t)]._weight<<color.at(k)<<std::endl;
-				}
-			}
-		}else{
-			for(uint k=0; k<num_vertices(*g); k++){
-				GRAPH2<<(*g)[k]._index<<" [label="<<(*g)[k]._index<<", weight="<<(*g)[k]._weight<<"];"<<std::endl;
-			}
-		}
-
-		GRAPH2<<"}";
-		GRAPH2.close();
-	}else{
-		std::cout<<"Error : Le nombre de couleur est insuffisant pour réaliser l'affichange"<<std::endl;
-	}
-}
-
-void Plot_OrientedGraph_All(OrientedGraph *go, const EntiersEntiers &Partition, const char* text, bool Color){
-	edge_to e1;
-	bool found;
-
-	if(Partition.size()<17){
-		std::vector<std::string> color;
-		color.push_back("[color=blue2, fontcolor=blue2];");
-		color.push_back("[color=red, fontcolor=red];");
-		color.push_back("[color=green, fontcolor=green];");
-		color.push_back("[color=turquoise, fontcolor=turquoise];");
-		color.push_back("[color=saddlebrown, fontcolor=saddlebrown];");
-		color.push_back("[color=indigo, fontcolor=indigo];");
-		color.push_back("[color=yellow, fontcolor=yellow2];");
-		color.push_back("[color=orange, fontcolor=orange];");
-		color.push_back("[color=olivedrab, fontcolor=olivedrab];");
-		color.push_back("[color=gold, fontcolor=gold];");
-		color.push_back("[color=slateblue2, fontcolor=slateblue2];");
-		color.push_back("[color=dimgrey, fontcolor=dimgrey];");
-		color.push_back("[color=cyan, fontcolor=cyan];");
-		color.push_back("[color=purple1, fontcolor=purpule1];");
-		color.push_back("[color=crimson, fontcolor=crimson];");
-		color.push_back("[color=black, fontcolor=black];");
-
-		std::ofstream fichier2 (text, std::ios::out);
-	    fichier2<<"digraph G {"<<std::endl;
-	    tie(vertexIto, vertexEndo) = vertices(*go);
-	    for (; vertexIto != vertexEndo; ++vertexIto) {
-	    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
-	    			*go);
-	    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
-					tie(e1,found)=edge(vertex(*vertexIto,*go),vertex(*neighbourIto,*go),*go);
-					fichier2<<(*go)[*vertexIto]._index<<" -> "<<(*go)[*neighbourIto]._index<<" [label="<<(*go)[e1]._weight<<", fontsize=10, fontcolor= blue];"<<std::endl;
-	    	}
-		}
-
-	    if(Color == true){
-			for(uint k=0; k<Partition.size(); k++){
-				for(uint j=0; j<Partition.at(k)->size(); j++)
-				{
-					fichier2<<Partition.at(k)->at(j)<<color.at(k)<<std::endl;
-				}
-			}
-		}
-
-		fichier2<<"}";
-		fichier2.close();
-
-	}else{
-		std::cout<<"Error : Le nombre de couleur est insuffisant pour réaliser l'affichange"<<std::endl;
-	}
-}
-
-
-void Affichage_OrientedGraph(OrientedGraph *go){
-	tie(vertexIto, vertexEndo) = vertices(*go);
-    for (; vertexIto != vertexEndo; ++vertexIto) {
-    	std::cout<<(*go)[*vertexIto]._index<<" -> ";
-    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
-    			*go);
-    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
-    		std::cout<<(*go)[*neighbourIto]._index<<" ";
-    	}
-    	std::cout<<std::endl;
-    }
-	std::cout<<std::endl;
-}
-
-void Affichage_UnorientedGraph(UnorientedGraph *g){
-	tie(vertexIt, vertexEnd) = vertices(*g);
-    for (; vertexIt != vertexEnd; ++vertexIt) {
-    	std::cout<<(*g)[*vertexIt]._index<<" -> ";
-    	tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
-    			*g);
-    	for (; neighbourIt != neighbourEnd; ++neighbourIt){
-    		std::cout<<(*g)[*neighbourIt]._index<<" ";
-    	}
-    	std::cout<<std::endl;
-    }
-	std::cout<<std::endl;
-}
-
-double Total_weight_edges(UnorientedGraph *g){
-	double Sum_weight_edges = 0.;
-	edge_t e1;
-	bool found;
-
-	tie(vertexIt, vertexEnd) = vertices(*g);
-	for (; vertexIt != vertexEnd; ++vertexIt) {
-		tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,*g);
-		for (; neighbourIt != neighbourEnd; ++neighbourIt){
-			if((*g)[*neighbourIt]._index>(*g)[*vertexIt]._index){
-				tie(e1,found)=edge(vertex(*vertexIt,*g),vertex(*neighbourIt,*g),*g);
-				Sum_weight_edges += (*g)[e1]._weight;
-				}
-		}
-	}
-
-	return Sum_weight_edges;
-}
-
-void Merge_Boost_Graph(OrientedGraph *go1, OrientedGraph *go2, std::vector<std::pair<int,int>> &connection, std::vector<double> &connection_weight){
-	edge_to e1;
-	bool found;
-
-	int nbr_go1 = num_vertices(*go1);
-	int nbr_go2 = num_vertices(*go2);
-
-	/*** Fusion ***/
-	if(nbr_go1 >= nbr_go2){
-		tie(vertexIto, vertexEndo) = vertices(*go2);
-		for (; vertexIto != vertexEndo; ++vertexIto){
-			vertex_to v0 = boost::add_vertex(*go1);
-			(*go1)[v0] = VertexProperties((*go2)[*vertexIto]._index, (*go2)[*vertexIto]._weight, 1 /*NORMAL_PIXEL*/);
-		}
-
-		tie(vertexIto, vertexEndo) = vertices(*go2);
-		for (; vertexIto != vertexEndo; ++vertexIto){
-			tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,*go2);
-			for (; neighbourIto != neighbourEndo; ++neighbourIto){
-				tie(e1,found)=edge(vertex(*vertexIto,*go2),vertex(*neighbourIto,*go2),*go2);
-				add_edge(*vertexIto + nbr_go1, *neighbourIto + nbr_go1, (*go2)[e1]._weight, *go1);
-			}
-		}
-
-		/*** Connection ***/
-		/* Fonctionne si l'ordre de nomation respecte l'ordre boost sinon possibilité d'identification par nom*/
-		for(uint i = 0; i < connection.size(); i++){
-			add_edge(connection.at(i).first, connection.at(i).second, connection_weight.at(i) , *go1);
-		}
-
-	}else{
-		tie(vertexIto, vertexEndo) = vertices(*go1);
-		for (; vertexIto != vertexEndo; ++vertexIto){
-			vertex_to v0 = boost::add_vertex(*go2);
-			(*go2)[v0] = VertexProperties((*go1)[*vertexIto]._index, (*go1)[*vertexIto]._weight, 1 /*NORMAL_PIXEL*/);
-		}
-
-		tie(vertexIto, vertexEndo) = vertices(*go1);
-		for (; vertexIto != vertexEndo; ++vertexIto){
-			tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,*go1);
-			for (; neighbourIto != neighbourEndo; ++neighbourIto){
-				tie(e1,found)=edge(vertex(*vertexIto,*go1),vertex(*neighbourIto,*go1),*go1);
-				add_edge(*vertexIto + nbr_go2, *neighbourIto + nbr_go2, (*go1)[e1]._weight, *go2);
-			}
-		}
-
-		/*** Connection ***/
-		/* Fonctionne si l'ordre de nomation respecte l'ordre boost sinon possibilité d'identification par nom*/
-		for(uint i = 0; i < connection.size(); i++){
-			add_edge(connection.at(i).first, connection.at(i).second, connection_weight.at(i) , *go2);
-		}
-
-	}
-
-}
-
-Entiers Random_Sort_Vector(uint size){
-
-	Entiers random_order;
-	for (uint i = 0 ; i<  size ; i++)
-		random_order.push_back(i);
-	for (uint j=0 ; j < random_order.size()-1 ; j++) {
-		int rand_pos = rand()%(size-j)+j;
-		int tmp      = random_order.at(j);
-		random_order.at(j) = random_order.at(rand_pos);
-		random_order.at(rand_pos) = tmp;
-	}
-
-	return random_order;
-}
-
-Entiers Random_Sort_Vector2(uint min, uint size){
-
-	Entiers random_order;
-	for (uint i = min ; i<  size ; i++)
-		random_order.push_back(i);
-	for (uint j = 0 ; j < random_order.size()-1 ; j++) {
-		int rand_pos = rand()%(random_order.size()-j)+j;
-		int tmp      = random_order.at(j);
-		random_order.at(j) = random_order.at(rand_pos);
-		random_order.at(rand_pos) = tmp;
-	}
-
-	return random_order;
-}
-
-double distance_t(std::pair<double,double> x, std::pair<double,double> y)
-{
-	double total = (x.first - y.first) * (x.first - y.first) ;
-	double diff2 = (x.second - y.second) * (x.second - y.second);
-	total +=  diff2;
-
-	return sqrt(total);
-}
-
-void simple_graph(UnorientedGraph *g)
-{
-	edge_t e1;
-    bool found;
-
-	tie(vertexIt, vertexEnd) = vertices(*g);
-	for (; vertexIt != vertexEnd; ++vertexIt) {
-		tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,*g);
-		
-		std::vector<uint> neight;
-		for (; neighbourIt != neighbourEnd; ++neighbourIt)
-			neight.push_back(*neighbourIt);
-		neight.push_back(-2);
-		sort(neight.begin(), neight.end());
-		
-		int tmp = -1;
-		uint cpt = 1;
-		double wi = 0.;
-		
-		for (uint i = 0; i < neight.size(); i++)
-		{
-			if(neight.at(i) > *vertexIt && *vertexIt != num_vertices(*g) - 1)
-			{
-				if(i != neight.size()-1)
-				{
-					tie(e1, found) = edge(vertex(*vertexIt, *g), vertex(neight.at(i), *g), *g);
-					if(tmp == neight.at(i))
-					{
-						wi += (*g)[e1]._weight;
-						cpt++;
-					}
-					else if(tmp != neight.at(i) & cpt != 1.)
-					{
-						remove_edge(*vertexIt,neight.at(i-1),*g);
-						add_edge(*vertexIt, neight.at(i-1), wi, *g);
-						wi = (*g)[e1]._weight;
-						cpt = 1;
-						tmp = neight.at(i);
-					}
-					else
-					{
-						wi = (*g)[e1]._weight;
-						cpt = 1.;
-						tmp = neight.at(i);
-					}
-				}
-				else
-				{
-					remove_edge(*vertexIt,neight.at(i-1),*g);
-					add_edge(*vertexIt, neight.at(i-1), wi, *g);
-				}
-			}
-		}
-	}
-}
-
-} } } // namespace paradevs tests boost_graph

+ 3553 - 46
src/tests/boost_graph/partitioning/utils.hpp

@@ -28,25 +28,28 @@
 #define TESTS_BOOST_GRAPH_PARTITIONING_UTILS_H 1
 
 #include <tests/boost_graph/partitioning/defs.hpp>
+
 #include <boost/graph/copy.hpp>
+#include <fstream>
 
 namespace paradevs { namespace tests { namespace boost_graph {
 
 void Global_Neigh_community(UnorientedGraph *g,
-                        const EntiersEntiers &Partition,
-                        Entiers *community, int vertex, 
-						int comm_in);
+                            const EntiersEntiers &Partition,
+                            Entiers *community, int vertex,
+                            int comm_in);
 
 OrientedGraphs Graph_Partition(const EntiersEntiers &Partition,
-                        OrientedGraph *go,
-                        UnorientedGraph *g,
-                        OutputEdgeList &outputedgelist,
-                        InputEdgeList &inputedgelist,
-                        Connections &connections);
+                               OrientedGraph *go,
+                               UnorientedGraph *g,
+                               OutputEdgeList &outputedgelist,
+                               InputEdgeList &inputedgelist,
+                               Connections &connections);
 
-void List_edge_partie(Entiers *Partie, OrientedGraph *go, 
-						Edges &edge_partie,
-                        OutputEdges &outputedgespartie);
+void List_edge_partie(Entiers *Partie,
+                      OrientedGraph *go,
+                      Edges &edge_partie,
+                      OutputEdges &outputedgespartie);
 
 void construire_graph(UnorientedGraph *g, OrientedGraph *graph);
 
@@ -64,7 +67,7 @@ double Calcul_poids(Entiers *partie, UnorientedGraph *g);
 bool Est_connexe(UnorientedGraph *g, EntiersEntiers Partition,
 						Entiers &part);
 
-void Affinage_equilibrage_charge(UnorientedGraph *g, 
+void Affinage_equilibrage_charge(UnorientedGraph *g,
 						EntiersEntiers &Partition);
 
 Entiers Neigh_community(UnorientedGraph *g, EntiersEntiers &Partition,
@@ -82,27 +85,27 @@ void projection(EntiersEntiers &Partition,ListEntiersEntiers::iterator lit);
 bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg,
 						ListEntiersEntiers &liste_corr, int val_reduc,
 						int &val_cpt);
-						
-bool contraction_HEM_tests(UnorientedGraph *g, Base_Graph &baseg, 
-						ListEntiersEntiers &liste_corr, int val_reduc, 
+
+bool contraction_HEM_tests(UnorientedGraph *g, Base_Graph &baseg,
+						ListEntiersEntiers &liste_corr, int val_reduc,
 						int &val_cpt);
-						
-bool contraction_HEM_max_degree_selection(UnorientedGraph *g, Base_Graph &baseg, 
-						ListEntiersEntiers &liste_corr, int val_reduc, 
+
+bool contraction_HEM_max_degree_selection(UnorientedGraph *g, Base_Graph &baseg,
+						ListEntiersEntiers &liste_corr, int val_reduc,
 						int &val_cpt);
 
 bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg,
-						ListEntiersEntiers &liste_corr, 
+						ListEntiersEntiers &liste_corr,
 						int val_reduc, int &val_cpt);
-						
+
 bool contraction_Random_Maching(UnorientedGraph *g, Base_Graph &baseg,
-                        ListEntiersEntiers &liste_corr, 
+                        ListEntiersEntiers &liste_corr,
                         int val_reduc,
                         int &val_cpt);
-                        
+
 Entiers Liste_adjacence(UnorientedGraph &g, int vertexs,
                         const Entiers &random_vertices);
-                        
+
 int rand_fini(int a, int b);
 
 int recherche_val2(const std::vector<float> &tab,float val);
@@ -141,13 +144,13 @@ void make_unoriented_graph(const OrientedGraph& og, UnorientedGraph& uog);
 
 void adjacence_ggp(int vertex, Entiers &sommets_adj, UnorientedGraph *g);
 
-double modif_Cout_coupe(const Entiers &P, int val, double cut, 
+double modif_Cout_coupe(const Entiers &P, int val, double cut,
 						UnorientedGraph *g);
 
 double Cluster_Weight(UnorientedGraph &g , const Entiers &cluster);
 
-double Best_Cut_cluster(EntiersEntiers &tab_cluster,Entiers *cluster1, 
-						Entiers *cluster2, int index_cluster1, 
+double Best_Cut_cluster(EntiersEntiers &tab_cluster,Entiers *cluster1,
+						Entiers *cluster2, int index_cluster1,
 						UnorientedGraph &g,std::string name);
 
 void Text_generator_graph(const char *texte, OrientedGraph *go);
@@ -156,37 +159,37 @@ void Graph_constructor_txt(const char* text, OrientedGraph * Og);
 
 int decimal(int valeur);
 
-double Diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition, 
+double Diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition,
 						int partie, int node, std::string name);
 
 std::vector<std::vector<int>> Vector_diff_cut_ratio(UnorientedGraph *g,
 						const EntiersEntiers &Partition, std::string name);
 
-void Affinache_gain_diff(UnorientedGraph *g, EntiersEntiers &Partition, 
+void Affinache_gain_diff(UnorientedGraph *g, EntiersEntiers &Partition,
 						double &cut, std::string name, double poids_moy);
 
 void Modif_vector_diff_cut_ratio(UnorientedGraph *g,
-						const EntiersEntiers &Partition, 
-						std::vector<std::vector<int>> &Diff_vector, 
+						const EntiersEntiers &Partition,
+						std::vector<std::vector<int>> &Diff_vector,
 						int recalcul1, int recalcul2, std::string name);
 
-double Gain_ratio(UnorientedGraph *g,const EntiersEntiers &Partition, 
+double Gain_ratio(UnorientedGraph *g,const EntiersEntiers &Partition,
 						int in, int out, int node, double ratio);
 
-std::vector<int> Vector_diff_cut_ratio_2(UnorientedGraph *g, 
+std::vector<int> Vector_diff_cut_ratio_2(UnorientedGraph *g,
 						const EntiersEntiers &Partition, std::string name);
 
-void Modif_vector_diff_cut_ratio_2(UnorientedGraph *g, 
-						const EntiersEntiers &Partition, 
+void Modif_vector_diff_cut_ratio_2(UnorientedGraph *g,
+						const EntiersEntiers &Partition,
 						std::vector<int> &Diff_vector, int node, std::string name);
 
-void Affinache_gain_diff_2(UnorientedGraph *g, EntiersEntiers &Partition, 
+void Affinache_gain_diff_2(UnorientedGraph *g, EntiersEntiers &Partition,
 						double &cut, std::string name, double poids_moy);
 
-double Modif_ratio_cut(UnorientedGraph *g,Entiers *Ss, Entiers *Sd, 
+double Modif_ratio_cut(UnorientedGraph *g,Entiers *Ss, Entiers *Sd,
 						int node, double ratio);
 
-double Diff_cut_ratio_bissection(UnorientedGraph *g, Entiers *part, 
+double Diff_cut_ratio_bissection(UnorientedGraph *g, Entiers *part,
 						int node, std::string name);
 
 EntiersEntiers Spectral_Partition(const char* text);
@@ -206,14 +209,14 @@ void Affichage_UnorientedGraph(UnorientedGraph *g);
 Entiers Liste_adjacence_tests(UnorientedGraph &g, int vertexs,
 						const Entiers &Index_Vertex);
 
-void Plot_UnorientedGraph_All(UnorientedGraph *g, 
-						const EntiersEntiers &Partition, 
+void Plot_UnorientedGraph_All(UnorientedGraph *g,
+						const EntiersEntiers &Partition,
 						const char* text, bool Color);
-						
-void Plot_OrientedGraph_All(OrientedGraph *go, 
-						const EntiersEntiers &Partition, 
+
+void Plot_OrientedGraph_All(OrientedGraph *go,
+						const EntiersEntiers &Partition,
 						const char* text, bool Color);
-						
+
 double Total_weight_edges(UnorientedGraph *g);
 
 bool Est_voisin(UnorientedGraph *g, int vertex, int vertex_select);
@@ -221,12 +224,12 @@ bool Est_voisin(UnorientedGraph *g, int vertex, int vertex_select);
 double In_modularity(UnorientedGraph *g , const Entiers &cluster);
 double Modularity(UnorientedGraph *g,const EntiersEntiers &part);
 
-bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg, 
+bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg,
 						ListEntiersEntiers &liste_corr, int val_reduc,
 						int &val_cpt);
 
-void Merge_Boost_Graph(OrientedGraph *go1, OrientedGraph *go2, 
-						std::vector<std::pair<int,int>> &connection, 
+void Merge_Boost_Graph(OrientedGraph *go1, OrientedGraph *go2,
+						std::vector<std::pair<int,int>> &connection,
 						std::vector<double> &connection_weight);
 
 Entiers Random_Sort_Vector(uint size);
@@ -236,6 +239,3510 @@ double distance_t(std::pair<double,double> x, std::pair<double,double> y);
 
 void simple_graph(UnorientedGraph *g);
 
+struct myclass
+{
+    bool operator() (Entiers *i, Entiers *j)
+    { return i->at(0) < j->at(0); }
+} myobject;
+
+struct myclass2
+{
+    bool operator() (Entiers *i, Entiers *j, UnorientedGraph *g)
+    { return Calcul_poids(i,g) < Calcul_poids(j,g); }
+} mon_tri;
+
+struct myclass3
+{
+	bool operator() (Entiers *i, Entiers *j)
+	{ return i->size() > j->size(); }
+} myobject_taille;
+
+struct myclass4
+{
+    bool operator() (int i, int j, UnorientedGraph *g)
+    { return (*g)[i]._weight > (*g)[j]._weight; }
+} mon_poids;
+
+/**
+ * Fonction de verification de la connexité d'un graphe
+ * @param *g : adresse d'un graphe de type boost graphe undirected
+ * @param Partition : vecteur contenant des vecteurs d'entiers [tableau contenant les parties de la partition]
+ * @param part : vecteur d'entier (une partie de la partition)
+ * @return un booleen
+ */
+bool Est_connexe(UnorientedGraph *g, EntiersEntiers Partition, Entiers &part)
+{
+    /*
+     * Copie du graphe contenu par l'adresse *g
+     */
+    UnorientedGraph copie_g;
+    copie_g = *g;
+
+    /*
+     * Modification du graphe copié afin de générer des sous graphes liés aux différentes parties
+     */
+    for (uint i=0; i<Partition.size()-1;i++)
+    {
+        for (uint j=1+i; j<Partition.size();j++)
+        {
+            for (uint k=0; k<Partition.at(i)->size();k++)
+            {
+                for (uint y=0; y<Partition.at(j)->size();y++)
+                {
+                    remove_edge(Partition.at(i)->at(k),Partition.at(j)->at(y),copie_g); //suppression de certains arcs
+                }
+            }
+        }
+    }
+
+    /*
+     * Objectif : déterminer s'il existe un chemin reliant tous les noeuds d'une même partie
+     * Méthode : partir d'un sommet de départ tiré aléatoirement dans la partie "part" et parcourir l'ensemble de ces voisins.
+     * Si le voisin recontré n'est pas contenu dans le vecteur "sommets" il est ajouté. Le processus est répété pour chaque
+     * nouveau sommet ajouté au vecteur.
+     * Résultat : si le nombre de sommets contenu dans le vecteur "part" est égale au nombre de sommets du vecteur "sommets"
+     * alors le graphe est connexe
+     */
+
+    uint val;
+    Entiers sommets;
+
+    if(part.size()==1)
+        val = 0;
+    else
+        val=rand_fini(0,part.size()-1); //tirage aléatoire d'un sommets
+
+    uint vertex = part.at(val);
+    sommets.push_back(vertex); //ajout du sommets à la lsite des sommets parcouru
+
+    /*
+     * Recherche de voisins n'appartenant pas à la liste des sommets parcourus
+     */
+    for(uint i = 0;i<sommets.size();i++){
+        UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+        UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+        tie(neighbourIt, neighbourEnd) = adjacent_vertices(
+            sommets.at(i),copie_g);
+        for (; neighbourIt != neighbourEnd; ++neighbourIt){
+            if(In_tab(sommets,*neighbourIt)!=1)
+                sommets.push_back(*neighbourIt);
+        }
+    }
+
+    /*
+     * Retour de la réponse vrai ou faux
+     */
+    if(part.size()!=sommets.size())
+        return false;
+    else
+        return true;
+
+}
+
+/**
+ * Fonction de projection
+ * @param Partition : vecteur contenant des vecteurs d'entiers [tableau contenant les parties de la partition]
+ * @param lit : itérateur sur une liste contenant une vecteur de vecteur d'entier
+ * @return
+ */
+
+/*
+ * Objectif : obtenir la correspondance entre les sommets d'un graphe Gn et celui de Gn-1
+ * Méthode : modification des sommets contenus dans "Partition" à l'aide de la liste de correspondance *lit
+ */
+
+void projection(EntiersEntiers &Partition,ListEntiersEntiers::iterator lit)
+{
+
+    /*
+     * Création d'un nouveau vecteur contenant les adresses d'autres vecteur d'entiers.
+     * Celui-ci est conçu pour recevoir les sommets contenus dans la liste de correspondance,
+     * correspondant à la projection des sommets du graphe Gn à celui de Gn-1
+     */
+    EntiersEntiers new_partition;
+    for(uint i = 0; i< Partition.size() ; i++)
+    {
+        Entiers *new_part = new Entiers();
+        for(uint j = 0 ; j<Partition.at(i)->size() ; j++)
+        {
+            for(uint k = 0; k<((*lit)->at(Partition.at(i)->at(j)))->size();k++){
+                new_part->push_back((*lit)->at(Partition.at(i)->at(j))->at(k));
+            }
+
+        }
+        new_partition.push_back(new_part);
+    }
+
+
+    /*
+     * Désalocation mémoire des pointeurs que contient "Partition"
+     */
+    for(EntiersEntiers::iterator it = Partition.begin(); it != Partition.end(); it++)
+    {
+        delete *it;
+        *it = NULL;
+    }
+
+    Partition = new_partition; // copie de new_partition dans Partition
+    for(uint i =0; i<Partition.size(); i++) {
+        // permet de trier chaque  sous vecteur de "Partition"
+        std::sort(Partition[i]->begin(),Partition[i]->end());
+    }
+
+    new_partition.clear();
+}
+
+/**
+ * Fonction qui calcul le poids d'une partie
+ * @param * part : adresse d'un vecteur d'entier, ici une partie de la partition
+ * @param *g : adresse d'un graphe de type boost graphe undirected
+ * @return un type double contenant le poids associé à la partie
+ */
+double Calcul_poids(Entiers *partie, UnorientedGraph *g)
+{
+    double poids=0; // initialisation du poids à 0
+
+    /*
+     * Pour chaque sommet de la partie concerné on ajoute son poids au poids total
+     */
+    for(uint j = 0; j<partie->size();j++){
+        poids+=(*g)[partie->at(j)]._weight;
+    }
+
+    return poids;
+}
+
+/**
+ * Fonction d'affinage suivant un critère de poids
+ * @param *g : adresse d'un graphe de type boost graphe undirected
+ * @param Partition : vecteur contenant des vecteurs d'entiers [tableau contenant les parties de la partition]
+ * @return modification de la partition
+ */
+void Affinage_equilibrage_charge(UnorientedGraph *g, EntiersEntiers &Partition)
+{
+    /*
+     * Calcule de la somme des poids du graphe et le poids moyen à atteindre
+     */
+    double poids_moyen = 0.;
+
+    for(uint i = 0; i < num_vertices(*g); i++) {
+        poids_moyen += (*g)[i]._weight;
+    }
+
+    // détermination du poids moyen à atteindre pour chaque partie
+    poids_moyen /= Partition.size();
+
+    std::vector < double > poids_parties;
+
+    /*
+     * Calcul du poids de chaque partie de la partition
+     */
+    for (uint i = 0; i < Partition.size(); i++) {
+        double tmp = Calcul_poids(Partition.at(i),g);
+
+        poids_parties.push_back(tmp);
+    }
+
+    // std::clog << "Poids initial des parties : " << std::endl;
+
+    // for (uint i = 0; i < poids_parties.size(); i++){
+    //     std::cout << poids_parties.at(i) << " ";
+    // }
+    // std::cout << "\n" << std::endl;
+
+    /*
+     * Le critère d'amélioration consiste à faire tendre vers 0 la somme
+     * des écarts entre le poids des parties et le poids moyen
+     * le "critere" est la somme pour chaque partie de la différence
+     * en valeurs absolues du poids
+     * d'une partie moins le poids moyen divisé par le nombre de parties
+     */
+
+    double critere = 0.;
+
+    for (uint i = 0; i < poids_parties.size(); i++){
+        critere += abs(poids_parties.at(i) - poids_moyen);
+    }
+    critere /= Partition.size();
+
+    // on conserve le poids maximum
+    double p_max = *max_element(poids_parties.begin(), poids_parties.end());
+
+    // std::cout << "Valeurs du criètre de départ : " << critere << std::endl;
+
+    // création d'un second critère légérement plsu faible que le premier
+    double best_critere = critere - 1e-7;
+    uint nbr_passage = 1; // initialisation du nombre de passages à 1
+
+    /*
+     * Tant que le critère n'est pas amélioré etque le nombre de
+     * passage est inférieur au nombre de parties on réalise
+     * des modifications sur la partition
+     */
+    while (best_critere < critere or nbr_passage < Partition.size()) {
+        critere = best_critere; //critere devient best_critere
+
+        // recherche la partie associé au poids maximum
+        int cpt = recherche_val_double(poids_parties,p_max);
+        bool decision = false; //initialisatio d'un booleen a false
+        int nbr_pass_interne = 0;
+
+        /*
+         * tirage aléatoire des sommets de la partie de poids maximum
+         */
+        Entiers random_orders = Random_Sort_Vector(Partition.at(cpt)->size());
+
+        /*
+         * Si le nombre de sommets d'une partie excéde les 400, on tire au hasar 400 sommets sans remise
+         * et on effectue les modifications (ceci permet d'eviter une explosion des temps de calcul)
+         */
+        int size;
+
+        if(Partition.at(cpt)->size()>400)
+            size = 400;
+        else
+            size = Partition.at(cpt)->size();
+
+        /*
+         * Seconde boucle Tant que sur les sommets d'une partie.
+         * Tant que le critere booleen est vrai et que le nombre de passe interne est inférieur au seuil size faire
+         */
+        while(decision!=true && nbr_pass_interne < size){
+            int vertex = random_orders.at(nbr_pass_interne); //tirage d'un sommets dans la parite de poids maximum
+            Entiers community = Neigh_community(g,Partition,vertex,cpt); // recherche des communautés voisines à ce sommet (s'il est au bord)
+            if(community.size()!=0) // s'il existe au moins une communauté voisine
+            {
+                std::vector<double> new_poids_parties; // initialisation d'un nouveau vecteur contenant des doubles
+                std::vector<double> tmp_critere; // initialisation d'un nouveau vecteur contenant des doubles
+
+                /*
+                 * Pour chacune des parties (communauté) voisine au sommet vertexs faire
+                 */
+                for(uint k = 0; k < community.size();k++)
+                {
+                    new_poids_parties = poids_parties; //copie du tableau de poids des parties dans new_poids_parties
+
+                    /*
+                     * Modification des poids des parties :
+                     * on ajoute le poids du sommets à la partie voisine
+                     * et on soustrait son poids à sa partie d'origine
+                     */
+                    new_poids_parties.at(community.at(k))+=(*g)[vertex]._weight;
+                    new_poids_parties.at(cpt)-=(*g)[vertex]._weight;
+
+                    /*
+                     * Calcul ldu nouveau critère associé à cette modification
+                     */
+                    double new_critere = 0.;
+
+                    for(uint i = 0; i<poids_parties.size();i++){
+                        new_critere += abs(new_poids_parties.at(i)-poids_moyen);
+                    }
+                    new_critere/=Partition.size();
+                    tmp_critere.push_back(new_critere); // enregistrement du résutlat dans le tableau tmp_critere
+                }
+                double val_min = *min_element(tmp_critere.begin(),tmp_critere.end()); // enregistrement de la valeur minimale du tableau tmp_critere
+                int val = recherche_val_double(tmp_critere,val_min); // recherche de la communauté correspondant à cette valeur
+
+                /*
+                 * Si la valeur associé est plus petite et que la partie selectionné n'est pas vérouillée faire
+                 */
+                if(val_min<critere && poids_parties.at(val)!=-1)
+                {
+                    /*
+                     * On change le sommet vertex de partie, il est déplacé vers la partie
+                     * qui permet la meilleure amélioration du critère
+                     */
+                    Partition.at(community.at(val))->push_back(vertex);
+                    suprim_val(*Partition.at(cpt),vertex);
+                    std::sort(Partition.at(community.at(val))->begin(), Partition.at(community.at(val))->end());
+
+                    /*
+                     * Vérification de la sauvegarde de la connexsité,
+                     * si se n'est pas le cas retour à l'état précédent
+                     */
+                    if(Est_connexe(g,Partition,*Partition.at(cpt))!=1)
+                    {
+                        suprim_val(*Partition.at(community.at(val)),vertex);
+                        Partition.at(cpt)->push_back(vertex);
+                        std::sort(Partition.at(cpt)->begin(), Partition.at(cpt)->end());
+                        // std::cout<<" C'EST MORT RETOUR EN ARRIERE ! "<<std::endl
+                            ;
+                    }
+                    else
+                    {
+                        poids_parties = new_poids_parties;
+                        decision = true;
+                        // std::cout<<" Modification reussi ! "<<std::endl;
+                    }
+                }
+            }
+            nbr_pass_interne++;
+        }
+        /*
+         * Si aucune modification n'a été réalisé pour cett partie de poids maximum
+         */
+        if(decision==false)
+        {
+            nbr_passage++; // augmentation du nombre de passage
+            poids_parties.at(cpt)=-1; // vérrouillage de la partie
+            // std::clog<<"nouveau passag ! "<<std::endl;
+        }
+        else
+        {
+            best_critere = 0.;
+
+            for(uint i = 0; i<poids_parties.size();i++){
+                best_critere += abs(poids_parties.at(i)-poids_moyen);
+            }
+            best_critere/=Partition.size();
+            nbr_passage = 0;
+        }
+
+        // std::clog<<"Poids des parties modifié : "<<std::endl;
+        // for(uint i = 0; i<poids_parties.size(); i++){
+        //     std::cout<<poids_parties.at(i)<<" ";
+        // }
+        // std::cout<<"\n"<<std::endl;
+        p_max = *max_element(poids_parties.begin(),poids_parties.end());
+        // std::cout<<"Valeurs du criètre : "<<critere<<std::endl;
+        // std::cout<<"Valeurs du best_criètre : "<<best_critere<<std::endl;
+        // std::cout<<"Nombre de passage : "<<nbr_passage<<std::endl;
+        // std::cout<<"\n"<<std::endl;
+
+    }
+}
+
+Entiers Neigh_community(UnorientedGraph *g, EntiersEntiers &Partition, int vertex, int comm_in)
+{
+    Entiers community;
+    int comm;
+    UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+    UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex,*g);
+    for (; neighbourIt != neighbourEnd; ++neighbourIt){
+        comm = In_community_dichotomie(Partition,*neighbourIt);
+        if(In_tab(community,comm)!=1 && comm!=comm_in)
+            community.push_back(comm);
+    }
+    return community;
+}
+
+void Affinage_recherche_locale(UnorientedGraph *g, EntiersEntiers &Partition, double &cut, std::string name)
+{
+    Entiers random_orders = Random_Sort_Vector(num_vertices(*g)); //gestion d'un tableau contenant tout les sommets et ranger de façon aléatoire
+
+    uint size = random_orders.size();
+
+    if(num_vertices(*g)>500)
+        size=500;
+
+    std::vector<std::vector<double> > tabe_cut;
+
+    //std::cout<<"Passage : "<<Partition.size()<<std::endl;
+    for(uint k = 0; k < Partition.size();k++){
+        std::vector<double> tmp;
+        double vol = 0.;
+        double cut = Modif_Cut_one_cluster(*Partition.at(k), *g, vol, name);
+        tmp.push_back(cut);
+        tmp.push_back(vol);
+        tabe_cut.push_back(tmp);
+    }
+
+    for(uint i = 0; i < size; i++){
+        if(random_orders.at(i)!=-1){
+            int vertex = random_orders.at(i);
+            //std::cout<<vertex<<std::endl;
+            int comm = In_community_dichotomie(Partition, vertex);
+            Entiers community = Neigh_community(g,Partition,vertex,comm);
+            std::vector<double> tmp_cut;
+
+            if(community.size()!=0 && Partition.at(comm)->size()!=1){
+                tmp_cut = modif_cut_tmp(g,Partition,tabe_cut,vertex,comm,community,cut,name);
+                /*for(uint z = 0; z<tmp_cut.size(); z++){
+                    std::cout<<tmp_cut.at(z)<<std::endl;
+                }
+                std::cout<<"\n"<<std::endl;*/
+                double cut_min = *min_element(tmp_cut.begin(),tmp_cut.end());
+                //std::cout<<"cout de coupe minimum de la liste : "<<cut_min<<std::endl;
+                if(cut_min<cut){
+                    // std::clog<<"Changement ! "<<std::endl;
+                    int tmp = recherche_val_double(tmp_cut,cut_min);
+                    cut=cut_min;
+                    Partition.at(community.at(tmp))->push_back(vertex);
+                    suprim_val(*Partition.at(comm),vertex);
+                    std::sort(Partition.at(community.at(tmp))->begin(), Partition.at(community.at(tmp))->end());
+                    tabe_cut.clear();
+                    for(uint k = 0; k < Partition.size();k++){
+                        std::vector<double> tmp;
+                        double vol = 0.;
+                        double cut = Modif_Cut_one_cluster(*Partition.at(k), *g, vol, name);
+                        tmp.push_back(cut);
+                        tmp.push_back(vol);
+                        tabe_cut.push_back(tmp);
+                    }
+
+                }
+            }
+
+            Modif_fonction_Gain_Cut(Partition,g,community,vertex,cut,name);
+
+
+            /*if(Est_connexe(g,Partition,*Partition.at(comm))!=1)
+              {
+              suprim_val(*Partition.at(community.at(tmp)),vertex);
+              Partition.at(comm)->push_back(vertex);
+              std::sort(*Partition.at(comm));
+              std::cout<<" C'EST MORT RETOUR EN ARRIERE ! "<<std::endl;
+              }*/
+
+        }
+    }
+}
+
+double Modif_Cut_one_cluster(Entiers &cluster, UnorientedGraph &g, double &vol,
+                             std::string name)
+{
+    edge_t e1;
+    bool found;
+    double cpt= 0.;
+    UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+    UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    if(name == "norm"){
+        for(uint i=0;i<cluster.size();i++){
+            tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i), g);
+            for (; neighbourIt != neighbourEnd; ++neighbourIt){
+                tie(e1,found)=edge(vertex(cluster[i],g),vertex(*neighbourIt,g),g);
+                if(In_tab(cluster,*neighbourIt)!=1){
+                    cpt+=g[e1]._weight;
+                }
+            }
+        }
+        vol = Cluster_Degree(g,cluster);
+    } else if(name == "ratio"){
+        for(uint i=0;i<cluster.size();i++){
+            tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i), g);
+            for (; neighbourIt != neighbourEnd; ++neighbourIt){
+                tie(e1,found)=edge(vertex(cluster[i],g),vertex(*neighbourIt,g),g);
+                if(In_tab(cluster,*neighbourIt)!=1){
+                    cpt+=g[e1]._weight;
+                }
+            }
+        }
+        vol = Cluster_Weight(g,cluster);
+    }
+    return cpt;
+}
+
+std::vector<double> modif_cut_tmp(UnorientedGraph *g, EntiersEntiers &Partition, std::vector<std::vector<double> > tabe_cut, int vertexs, int comm_in, Entiers community, double cut,std::string name){
+	edge_t e1;
+	bool found;
+	//std::cout<<"le sommet tiré est : "<<vertexs<<std::endl;
+
+	if(name == "cut")
+	{
+		std::vector<double> modif_cut(community.size());
+		double cpt_comm_in;
+		double cpt_comm_out;
+		for(uint i =0; i<community.size(); i++){
+			double tmp_cut = cut;
+			cpt_comm_in=0;
+			cpt_comm_out=0;
+
+    UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+    UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs,*g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				tie(e1,found)=edge(vertex(vertexs,*g),vertex(*neighbourIt,*g),*g);
+				if(In_tab(*Partition.at(comm_in),*neighbourIt)==1)
+					cpt_comm_in+=(*g)[e1]._weight;
+				else if(In_tab(*Partition.at(community.at(i)),*neighbourIt)==1)
+					cpt_comm_out+=(*g)[e1]._weight;
+			}
+
+			tmp_cut+=cpt_comm_in;
+			tmp_cut-=cpt_comm_out;
+
+			modif_cut.at(i)=tmp_cut;
+		}
+		return modif_cut;
+	}
+	else if(name == "norm"){
+		std::vector<double> modif_cut(community.size());
+		double cpt_comm_in;
+		double cpt_comm_out;
+		double tmp_cut;
+
+		for(uint i =0; i<community.size(); i++){
+			std::vector<std::vector<double> > tab_cut = tabe_cut;
+
+			tmp_cut =0.;
+			cpt_comm_in=0.;
+			cpt_comm_out=0.;
+
+    UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+    UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs,*g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				tie(e1,found)=edge(vertex(vertexs,*g),vertex(*neighbourIt,*g),*g);
+				if(In_tab(*Partition.at(comm_in),*neighbourIt)==1)
+					cpt_comm_in+=(*g)[e1]._weight;
+				else if(In_tab(*Partition.at(community.at(i)),*neighbourIt)==1)
+					cpt_comm_out+=(*g)[e1]._weight;
+			}
+
+			cpt_comm_in/=2.;
+			cpt_comm_out/=2.;
+
+			tab_cut.at(comm_in).at(0)+=cpt_comm_in;
+			tab_cut.at(comm_in).at(0)-=cpt_comm_out;
+			tab_cut.at(comm_in).at(1)-= Degree(*g ,vertexs);
+
+			tab_cut.at(community.at(i)).at(0)+=cpt_comm_in;
+			tab_cut.at(community.at(i)).at(0)-=cpt_comm_out;
+			tab_cut.at(community.at(i)).at(1)+= Degree(*g ,vertexs);
+
+			for(uint j = 0; j < tab_cut.size();j++){
+				tmp_cut+=((tab_cut.at(j).at(0))/(tab_cut.at(j).at(1)));
+			}
+
+			modif_cut.at(i)=tmp_cut;
+		}
+	}else if(name == "ratio"){
+		std::vector<double> modif_cut(community.size());
+		double cpt_comm_in;
+		double cpt_comm_out;
+		double tmp_cut;
+
+		for(uint i =0; i<community.size(); i++){
+			std::vector<std::vector<double> > tab_cut = tabe_cut;
+
+			tmp_cut =0.;
+			cpt_comm_in=0.;
+			cpt_comm_out=0.;
+
+    UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+    UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs,*g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				tie(e1,found)=edge(vertex(vertexs,*g),vertex(*neighbourIt,*g),*g);
+				if(In_tab(*Partition.at(comm_in),*neighbourIt)==1)
+					cpt_comm_in+=(*g)[e1]._weight;
+				else if(In_tab(*Partition.at(community.at(i)),*neighbourIt)==1)
+					cpt_comm_out+=(*g)[e1]._weight;
+			}
+
+			/*cpt_comm_in/=2.;
+			cpt_comm_out/=2.;*/
+
+			tab_cut.at(comm_in).at(0)+=cpt_comm_in;
+			tab_cut.at(comm_in).at(0)-=cpt_comm_out;
+			tab_cut.at(comm_in).at(1)-= (*g)[vertexs]._weight;
+
+			tab_cut.at(community.at(i)).at(0)+=cpt_comm_in;
+			tab_cut.at(community.at(i)).at(0)-=cpt_comm_out;
+			tab_cut.at(community.at(i)).at(1)+= (*g)[vertexs]._weight;
+
+			for(uint j = 0; j < tab_cut.size();j++){
+				tmp_cut+=((tab_cut.at(j).at(0))/(tab_cut.at(j).at(1)));
+			}
+
+			modif_cut.at(i)=tmp_cut;
+		}
+		return modif_cut;
+	}
+}
+void Modif_fonction_Gain_Cut(EntiersEntiers &Partition,UnorientedGraph *g, Entiers &community, int val, double &cut,std::string name)
+{
+	/*std::cout<<"Nombre de communauté voisine : "<<community.size()<<std::endl;
+	std::cout<<"\n"<<std::endl;*/
+	for(uint i = 0; i<community.size();i++){
+		EntiersEntiers new_partition;
+		for(uint k = 0; k < Partition.size();k++){
+			Entiers * tmp = new Entiers();
+			for(uint j = 0;j<Partition.at(k)->size();j++){
+				tmp->push_back(Partition.at(k)->at(j));
+			}
+			new_partition.push_back(tmp);
+		}
+
+
+		new_partition.at(community.at(i))->push_back(val);
+		suprim_val(*new_partition.at(In_community_dichotomie(Partition,val)),val);
+		std::sort(new_partition.at(community.at(i))->begin(),
+                    new_partition.at(community.at(i))->end());
+
+		double coupe = Cut_cluster(new_partition,*g,name);
+
+		//std::cout<<"cout de coupe : "<<coupe<<std::endl;
+		if(coupe<cut)
+		{
+			for(EntiersEntiers::iterator it = Partition.begin(); it != Partition.end(); it++)
+			{
+				delete *it;
+				*it = NULL;
+			}
+			Partition = new_partition;
+			cut = coupe;
+		}
+		else
+		{
+			for(EntiersEntiers::iterator it = new_partition.begin(); it != new_partition.end(); it++)
+			{
+				delete *it;
+				*it = NULL;
+			}
+		}
+	}
+}
+
+bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
+	UnorientedGraph *gtmp = new UnorientedGraph();
+	boost::copy_graph(*g, *gtmp);//, Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
+	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
+	edge_t e1,e2; // Iterateurs sur les arcs
+	bool found;
+	uint nbr_vertex = num_vertices(*gtmp);
+	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
+	/*
+	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
+	 * aléatoirement afin de simuler un tirage aléatoire
+	 */
+
+	Entiers Random_list_vertices = Random_Sort_Vector(nbr_vertex);
+
+	/*
+	 * Pour chaque sommet non verrouiller faire ....
+	 */
+
+	//std::cout<<"Nouvelle contraction !!!"<<std::endl;
+	//std::cout<<std::endl;
+	for(uint i=0; i<nbr_vertex; i++){
+		int vertexs = Random_list_vertices[i]; // Index_Vertex.at(Random_list_vertices.at(i));
+		//std::cout<<"Le sommet tiré est : "<<vertexs<<std::endl;
+		if(vertexs!=-1){
+			Entiers liste_voisin = Liste_adjacence(*gtmp,vertexs,Random_list_vertices); // Recherche des sommets adjacents au sommets  tiré
+			if(liste_voisin.size()!=0){
+				/*
+				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
+				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
+				 * le même poids, on selectionne le sommet d'index le plus petit
+				 */
+				double poids_a = 0.;
+				int best_vertexs = -1;
+				for(uint j=0;j<liste_voisin.size();j++){
+					tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
+					if((*gtmp)[e1]._weight>poids_a){
+						best_vertexs = liste_voisin[j];
+						poids_a = (*gtmp)[e1]._weight;
+					}
+				}
+
+
+				Entiers * couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
+				int vertex_delete = std::max(vertexs, best_vertexs); // Sommet d'index le plus grand (qui sera détruit)
+				//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
+				int vertex_save = std::min(vertexs,best_vertexs); // Sommet d'identifiant le plus petit (qui sera conservé)
+				//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
+
+				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
+				/*
+				 * On ajoute au tableau "couple" le couple de sommet à fusionner
+				 */
+				couple->push_back(vertex_save);
+				couple->push_back(vertex_delete);
+				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
+
+				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
+
+				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
+				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
+    UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+    UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
+
+				/*
+				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
+				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
+				 * du processus]
+				 */
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_save.push_back(*neighbourIt);
+				}
+
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_delete.push_back(*neighbourIt);
+				}
+
+				/*
+				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
+				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
+				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
+				 */
+				for(uint j=0;j<neigh_vertex_delete.size();j++){
+					if(In_tab(neigh_vertex_save,neigh_vertex_delete[j])==1){
+						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+					else
+					{
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+				}
+
+				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
+				/*
+				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
+				 */
+				Random_list_vertices[i]=-1;
+				Random_list_vertices[recherche_val(Random_list_vertices,best_vertexs)]=-1;
+				val_cpt--;
+				// std::cout<<val_cpt<<std::endl;
+			}
+			else{
+				/*
+				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
+				 * alors on l'ajoute à la liste de correspondance des sommets et on
+				 * le verrouille
+				 */
+				Entiers *couple = new Entiers();
+				couple->push_back(Random_list_vertices.at(i));
+				tableau_de_correspondance->push_back(couple);
+				Random_list_vertices[i]=-1;
+			}
+		}
+
+		if(val_cpt == val_reduc){
+			for(uint j=i+1; j <nbr_vertex; j++){
+				if(Random_list_vertices[j] !=-1){
+				Entiers *couple = new Entiers();
+				couple->push_back(Random_list_vertices.at(j));
+				tableau_de_correspondance->push_back(couple);}
+			}
+			break;
+		}
+	}
+
+	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
+	// std::cout<<"\n"<<std::endl;
+	/*
+	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
+	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
+	 * des sommets
+	 */
+	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
+		//std::cout<<"Noeuds a supprimer : "<<sommets_a_detruire.at(j)<<std::endl;
+		remove_vertex(sommets_a_detruire[j],*gtmp);
+	}
+
+	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
+
+	liste_corr.push_back(tableau_de_correspondance);
+	// std::cout<<"\n"<<std::endl;
+	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
+
+	if(val_cpt == val_reduc)
+		return true;
+	else
+		return false;
+
+}
+
+bool contraction_HEM_tests(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
+	UnorientedGraph *gtmp = new UnorientedGraph();
+	boost::copy_graph(*g, *gtmp);
+	Entiers Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
+	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
+	edge_t e1,e2; // Iterateurs sur les arcs
+	bool found;
+	uint nbr_vertex = num_vertices(*gtmp);
+	//std::cout<<"val_reduc  : "<<val_reduc<<std::endl;
+	//std::cout<<"nbr_vertex : "<<nbr_vertex<<std::endl;
+	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
+	/*
+	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
+	 * aléatoirement afin de simuler un tirage aléatoire
+	 */
+	for (uint i=0 ; i<nbr_vertex ; i++)
+		Index_Vertex.push_back(i);
+
+	Entiers Random_list_vertices = Random_Sort_Vector(nbr_vertex);
+
+	/*
+	 * Pour chaque sommet non verrouiller faire ....
+	 */
+
+	//std::cout<<"Nouvelle contraction !!!"<<std::endl;
+	//std::cout<<std::endl;
+	for(uint i=0; i<nbr_vertex; i++){
+		int vertexs = Index_Vertex.at(Random_list_vertices.at(i));
+		//std::cout<<"Le sommet tiré est : "<<(*gtmp)[vertexs]._index<<" ça place est : "<<vertexs<<" place : "<<i<<std::endl;
+		if(vertexs!=-1){
+			Entiers liste_voisin = Liste_adjacence_tests(*gtmp,vertexs,Index_Vertex); // Recherche des sommets adjacents au sommets  tiré
+			if(liste_voisin.size()!=0){
+				/*
+				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
+				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
+				 * le même poids, on selectionne le sommet d'index le plus petit
+				 */
+				double poids_a = 0.;
+				int best_vertexs = -1;
+				for(uint j=0;j<liste_voisin.size();j++){
+					tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
+					if((*gtmp)[e1]._weight>poids_a){
+						best_vertexs = liste_voisin[j];
+						poids_a = (*gtmp)[e1]._weight;
+					}
+				}
+
+
+				Entiers *couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
+				int vertex_delete = std::max(vertexs, best_vertexs); // Sommet d'index le plus grand (qui sera détruit)
+				//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
+				int vertex_save = std::min(vertexs,best_vertexs); // Sommet d'identifiant le plus petit (qui sera conservé)
+				//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
+
+				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
+				/*
+				 * On ajoute au tableau "couple" le couple de sommet à fusionner
+				 */
+				couple->push_back(vertex_save);
+				couple->push_back(vertex_delete);
+				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
+
+				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
+
+				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
+				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
+    UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
+
+				/*
+				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
+				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
+				 * du processus]
+				 */
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_save.push_back(*neighbourIt);
+					//std::cout<<(*gtmp)[*neighbourIt]._index<<" ";
+				}
+				//std::cout<<std::endl;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_delete.push_back(*neighbourIt);
+					//std::cout<<(*gtmp)[*neighbourIt]._index<<" ";
+				}
+				//std::cout<<std::endl;
+
+				sort(neigh_vertex_save.begin(),neigh_vertex_save.end());
+				sort(neigh_vertex_delete.begin(),neigh_vertex_delete.end());
+				/*
+				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
+				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
+				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
+				 */
+
+				for(uint j=0;j<neigh_vertex_delete.size();j++){
+					//std::cout<<"* "<<neigh_vertex_delete.size()<<" "<<(*gtmp)[neigh_vertex_delete[j]]._index<<std::endl;
+					if(neigh_vertex_save.size() != 0){
+						if(In_tab_dichotomie(neigh_vertex_save,neigh_vertex_delete[j])==1){
+						//	std::cout<<"*p"<<std::endl;
+							tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+							tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+							(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
+							remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+						}
+						else
+						{
+							//std::cout<<"*t"<<std::endl;
+							tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+							add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+							remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+						}
+					}else{
+						//std::cout<<"*t"<<std::endl;
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+				}
+				//std::cout<<"**"<<std::endl;
+				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
+				/*
+				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
+				 */
+				Index_Vertex.at(Random_list_vertices.at(i))=-1;
+				Index_Vertex.at(best_vertexs)=-1;
+				val_cpt--;
+				//std::cout<<"***"<<std::endl;
+				//std::cout<<std::endl;
+			}
+			else{
+				/*
+				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
+				 * alors on l'ajoute à la liste de correspondance des sommets et on
+				 * le verrouille
+				 */
+				Entiers *couple = new Entiers();
+				couple->push_back(vertexs);
+				tableau_de_correspondance->push_back(couple);
+				Index_Vertex.at(Random_list_vertices.at(i))=-1;
+			}
+		}
+
+		if(val_cpt == val_reduc){
+			//std::cout<<"égalité"<<std::endl;
+			for(uint j=i+1; j < nbr_vertex; j++){
+				if(Index_Vertex.at(Random_list_vertices.at(j)) != -1){
+				Entiers *couple = new Entiers();
+				couple->push_back(Index_Vertex.at(Random_list_vertices.at(j)));
+				tableau_de_correspondance->push_back(couple);}
+			}
+			break;
+		}
+	}
+
+	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
+	// std::cout<<"\n"<<std::endl;
+	/*
+	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
+	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
+	 * des sommets
+	 */
+	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
+		//std::cout<<"Noeuds a supprimer : "<<sommets_a_detruire.at(j)<<std::endl;
+		remove_vertex(sommets_a_detruire[j],*gtmp);
+	}
+
+	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
+
+	liste_corr.push_back(tableau_de_correspondance);
+	// std::cout<<"\n"<<std::endl;
+	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
+
+	if(val_cpt == val_reduc)
+		return true;
+	else
+		return false;
+
+}
+
+bool contraction_HEM_max_degree_selection(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
+	UnorientedGraph *gtmp = new UnorientedGraph();
+	boost::copy_graph(*g, *gtmp);
+	Entiers Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
+	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
+	edge_t e1,e2; // Iterateurs sur les arcs
+	bool found;
+	uint nbr_vertex = num_vertices(*gtmp);
+	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
+	/*
+	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
+	 * aléatoirement afin de simuler un tirage aléatoire
+	 */
+	for (uint i=0 ; i<nbr_vertex ; i++)
+		Index_Vertex.push_back(i);
+
+	Entiers Random_list_vertices = Random_Sort_Vector(nbr_vertex);
+	/*
+	 * Pour chaque sommet non verrouiller faire ....
+	 */
+
+	//std::cout<<"Nouvelle contraction !!!"<<std::endl;
+	for(uint i=0; i<nbr_vertex; i++){
+		int vertexs = Index_Vertex.at(Random_list_vertices.at(i));
+		//std::cout<<"Le sommet tiré est : "<<(*gtmp)[vertexs]._index<<" ça place est : "<<Random_list_vertices.at(i)<<" place : "<<i<<std::endl;
+		if(vertexs!=-1){
+			Entiers liste_voisin = Liste_adjacence_tests(*gtmp,vertexs,Index_Vertex); // Recherche des sommets adjacents au sommets  tiré
+			if(liste_voisin.size()!=0){
+				/*
+				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
+				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
+				 * le même poids, on selectionne le sommet d'index le plus petit
+				 */
+				double poids_a = -1.;
+				int best_vertexs = -1;
+				for(uint j=0;j<liste_voisin.size();j++){
+					tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
+					if((*gtmp)[e1]._weight>poids_a){
+						best_vertexs = liste_voisin[j];
+						poids_a = (*gtmp)[e1]._weight;
+					}
+				}
+
+				Entiers *couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
+
+				/* Sélection  du sommet possedant un degrès maximum */
+				std::pair<double,int> couple1, couple2, best_min, best_max;
+				couple1.first = Degree(*gtmp,vertexs);
+				couple1.second = vertexs;
+				couple2.first = Degree(*gtmp,best_vertexs);
+				couple2.second = best_vertexs;
+				best_min = std::min(couple1,couple2);
+				best_max = std::max(couple1,couple2);
+				int vertex_delete = best_min.second; // Sommet d'index le plus grand (qui sera détruit)
+				//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
+				int vertex_save = best_max.second; // Sommet d'identifiant le plus petit (qui sera conservé)
+				//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
+
+				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
+				/*
+				 * On ajoute au tableau "couple" le couple de sommet à fusionner
+				 */
+				couple->push_back(vertex_save);
+				couple->push_back(vertex_delete);
+				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
+
+				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
+
+				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
+				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
+
+				/*
+				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
+				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
+				 * du processus]
+				 */
+    UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+    UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+						neigh_vertex_save.push_back(*neighbourIt);
+				}
+
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
+
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+						neigh_vertex_delete.push_back(*neighbourIt);
+				}
+
+				sort(neigh_vertex_save.begin(),neigh_vertex_save.end());
+				sort(neigh_vertex_delete.begin(),neigh_vertex_delete.end());
+
+				/*
+				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
+				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
+				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
+				 */
+				for(uint j=0;j<neigh_vertex_delete.size();j++){
+					if(In_tab_dichotomie(neigh_vertex_save,neigh_vertex_delete[j])==1){
+						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+					else
+					{
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+				}
+
+				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
+				/*
+				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
+				 */
+				Index_Vertex.at(Random_list_vertices.at(i))=-1;
+				Index_Vertex.at(best_vertexs)=-1;
+				val_cpt--;
+			}
+			else{
+				/*
+				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
+				 * alors on l'ajoute à la liste de correspondance des sommets et on
+				 * le verrouille
+				 */
+				Entiers *couple = new Entiers();
+				couple->push_back(vertexs);
+				tableau_de_correspondance->push_back(couple);
+				Index_Vertex.at(Random_list_vertices.at(i))=-1;
+			}
+		}
+
+		if(val_cpt == val_reduc){
+			for(uint j=i+1; j < nbr_vertex; j++){
+				if(Index_Vertex.at(Random_list_vertices.at(j)) != -1){
+				Entiers *couple = new Entiers();
+				couple->push_back(Index_Vertex.at(Random_list_vertices.at(j)));
+				tableau_de_correspondance->push_back(couple);}
+			}
+			break;
+		}
+	}
+
+	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
+
+	/*
+	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
+	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
+	 * des sommets
+	 */
+
+	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
+		remove_vertex(sommets_a_detruire[j],*gtmp);
+	}
+
+	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
+	liste_corr.push_back(tableau_de_correspondance);
+	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
+
+	if(val_cpt == val_reduc)
+		return true;
+	else
+		return false;
+
+}
+
+bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
+	UnorientedGraph *gtmp = new UnorientedGraph();
+	boost::copy_graph(*g, *gtmp);
+	Entiers Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
+	std::vector<double> vertex_degree;
+	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
+	edge_t e1,e2; // Iterateurs sur les arcs
+	bool found;
+	uint nbr_vertex = num_vertices(*gtmp);
+	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
+	int cpt = nbr_vertex;
+	/*
+	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
+	 * aléatoirement afin de simuler un tirage aléatoire
+	 */
+
+	for (uint i=0 ; i<nbr_vertex ; i++){
+		Index_Vertex.push_back(i);
+		vertex_degree.push_back(Degree(*g,i));
+	}
+
+	while(cpt != 0){
+		double max_weight = *std::max_element(vertex_degree.begin(),vertex_degree.end());
+		int vertexs, compteur;
+		//std::cout<<"max_weight : "<<max_weight<<std::endl;
+		//Entiers Vertex_select;
+		for(uint id = 0; id <vertex_degree.size(); id++){
+			if(vertex_degree.at(id) == max_weight){
+				compteur = id;
+				vertexs = Index_Vertex.at(id);
+				break;
+			}
+		}
+		//std::cout<<"min : "<<max_weight<<" - compteur : "<<(*gtmp)[compteur]._index;
+
+		//std::cout<<"Le sommet tiré est : "<<(*gtmp)[vertexs]._index<<" ça place est : "<<compteur<<std::endl;
+		Entiers liste_voisin = Liste_adjacence_tests(*gtmp,vertexs,Index_Vertex); // Recherche des sommets adjacents au sommets  tiré
+		if(liste_voisin.size() != 0){
+			/*
+			 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
+			 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
+			 * le même poids, on selectionne le sommet d'index le plus petit
+			 */
+			std::vector<double> Neight_weight, Best_neight;
+			int best_vertexs;
+			for(uint j=0;j<liste_voisin.size();j++){
+				tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
+				Neight_weight.push_back((*gtmp)[e1]._weight);
+			}
+
+			max_weight = *std::max_element(Neight_weight.begin(),Neight_weight.end());
+			for(uint j=0;j<liste_voisin.size();j++){
+				if(Neight_weight.at(j) == max_weight)
+					Best_neight.push_back(liste_voisin.at(j));
+			}
+
+			if(Best_neight.size() > 1){
+				int ind;
+				double deg =1000000000;
+				double tmp_deg;
+				for(uint j=0;j<Best_neight.size();j++){
+					tmp_deg = Degree(*gtmp,Best_neight.at(j));
+					if(tmp_deg < deg){
+						deg = tmp_deg;
+						ind = j;
+					}
+				}
+				best_vertexs = Best_neight.at(ind);
+			}else{
+				best_vertexs = Best_neight.at(0);
+			}
+
+			//std::cout<<" -> "<<(*gtmp)[best_vertexs]._index;
+			Entiers *couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
+
+			/* Sélection  du sommet possedant un degrès maximum */
+			std::pair<double,int> couple1, couple2, best_min, best_max;
+			couple1.first = Degree(*gtmp,vertexs);
+			couple1.second = vertexs;
+			couple2.first = Degree(*gtmp,best_vertexs);
+			couple2.second = best_vertexs;
+			best_min = std::min(couple1,couple2);
+			best_max = std::max(couple1,couple2);
+			int vertex_delete = best_min.second; // Sommet d'index le plus grand (qui sera détruit)
+			//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
+			int vertex_save = best_max.second; // Sommet d'identifiant le plus petit (qui sera conservé)
+			//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
+
+			sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
+			/*
+			 * On ajoute au tableau "couple" le couple de sommet à fusionner
+			 */
+			couple->push_back(vertex_save);
+			couple->push_back(vertex_delete);
+			tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
+
+			remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
+
+			Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
+			Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
+
+			/*
+			 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
+			 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
+			 * du processus]
+			 */
+    UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+    UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_save.push_back(*neighbourIt);
+			}
+
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
+
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_delete.push_back(*neighbourIt);
+			}
+
+			sort(neigh_vertex_save.begin(),neigh_vertex_save.end());
+			sort(neigh_vertex_delete.begin(),neigh_vertex_delete.end());
+
+			/*
+			 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
+			 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
+			 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
+			 */
+			for(uint j=0;j<neigh_vertex_delete.size();j++){
+				if(neigh_vertex_save.size() != 0){
+					if(In_tab_dichotomie(neigh_vertex_save,neigh_vertex_delete[j])==1){
+						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+					else
+					{
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+				}else{
+					tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+					add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+					remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+				}
+			}
+
+			(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
+			/*
+			 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
+			 */
+			Index_Vertex.at(compteur)=-1;
+			vertex_degree.at(compteur)=-1;
+			Index_Vertex.at(best_vertexs)=-1;
+			vertex_degree.at(best_vertexs)=-1;
+			val_cpt--;
+			cpt -= 2;
+			//std::cout<<" ** "<<std::endl;
+			//std::cout<<cpt<<std::endl;
+		}
+		else{
+			/*
+			 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
+			 * alors on l'ajoute à la liste de correspondance des sommets et on
+			 * le verrouille
+			 */
+			Entiers *couple = new Entiers();
+			couple->push_back(vertexs);
+			tableau_de_correspondance->push_back(couple);
+			Index_Vertex.at(compteur)=-1;
+			vertex_degree.at(compteur)=-1;
+			cpt --;
+			//std::cout<<" * "<<std::endl;
+		}
+
+		if(val_cpt == val_reduc){
+			for(uint j=0; j < nbr_vertex; j++){
+				if(Index_Vertex.at(j) != -1){
+				Entiers *couple = new Entiers();
+				couple->push_back(Index_Vertex.at(j));
+				tableau_de_correspondance->push_back(couple);}
+			}
+			break;
+		}
+	}
+
+	//std::cout<<"cpt : "<<cpt<<std::endl;
+	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
+
+	/*
+	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
+	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
+	 * des sommets
+	 */
+
+	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
+		remove_vertex(sommets_a_detruire[j],*gtmp);
+	}
+
+	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
+	liste_corr.push_back(tableau_de_correspondance);
+	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
+
+	if(val_cpt == val_reduc)
+		return true;
+	else
+		return false;
+
+}
+
+bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
+	UnorientedGraph *gtmp = new UnorientedGraph();
+	boost::copy_graph(*g, *gtmp);
+	Entiers Index_Vertex; // Initialisation du tableau de sommets rangés aléatoirements
+	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
+	edge_t e1,e2; // Iterateurs sur les arcs
+	bool found;
+	uint nbr_vertex = num_vertices(*gtmp);
+	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
+	/*
+	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
+	 * aléatoirement afin de simuler un tirage aléatoire
+	 */
+	for (uint i=0 ; i<nbr_vertex ; i++)
+		Index_Vertex.push_back(i);
+
+	Entiers Random_list_vertices = Random_Sort_Vector(nbr_vertex);
+
+	/*
+	 * Pour chaque sommet non verrouiller faire ....
+	 */
+
+	//std::cout<<"Nouvelle contraction !!!"<<std::endl;
+	for(uint i=0; i<nbr_vertex; i++){
+		int vertexs = Index_Vertex.at(Random_list_vertices.at(i));
+		//std::cout<<"Le sommet tiré est : "<<(*gtmp)[vertexs]._index<<" ça place est : "<<Random_list_vertices.at(i)<<" place : "<<i<<std::endl;
+		if(vertexs!=-1){
+			Entiers liste_voisin = Liste_adjacence_tests(*gtmp,vertexs,Index_Vertex); // Recherche des sommets adjacents au sommets  tiré
+			sort(liste_voisin.begin(),liste_voisin.end());
+			if(liste_voisin.size()!=0){
+				/*
+				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
+				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
+				 * le même poids, on selectionne le sommet d'index le plus petit
+				 */
+				/*std::cout<<"Le sommet tiré a des voisins "<<std::endl;
+				for(uint id = 0; id<liste_voisin.size(); id++){
+					std::cout<<(*gtmp)[liste_voisin.at(id)]._index<<" ";
+				}
+				std::cout<<std::endl;*/
+				double poids_a = -1.;
+				std::vector<double> adjacent_weight;
+				//std::cout<<"adjacent_weight"<<std::endl;
+				for(uint j=0;j<liste_voisin.size();j++){
+					tie(e1,found)=edge(vertex(vertexs,*gtmp),vertex(liste_voisin[j],*gtmp),*gtmp);
+					adjacent_weight.push_back((*gtmp)[e1]._weight);
+					//std::cout<<(*gtmp)[e1]._weight<<" ";
+				}
+				//std::cout<<std::endl;
+				//std::cout<<"Top *"<<std::endl;
+				double max_weight = *std::max_element(adjacent_weight.begin(),adjacent_weight.end());
+				//std::cout<<"max_weight : "<<max_weight<<std::endl;
+				Entiers Vertex_select;
+				for(uint id = 0; id <adjacent_weight.size(); id++){
+					if(adjacent_weight.at(id) == max_weight)
+						Vertex_select.push_back(liste_voisin.at(id));
+				}
+
+				int index = 0;
+				if(Vertex_select.size()>1){
+					//std::cout<<"Top **"<<std::endl;
+					for(uint id = 0; id<Vertex_select.size(); id++){
+						suprim_val(liste_voisin,Vertex_select.at(id)); /*** modification possible ***/
+					}
+
+					//std::cout<<"Top ***"<<std::endl;
+					adjacent_weight.clear();
+					for(uint id_Vs = 0; id_Vs<Vertex_select.size(); id_Vs++){
+						double neigh_weight = 0.;
+						for(uint id_Lv = 0; id_Lv<liste_voisin.size(); id_Lv++){
+							//std::cout<<"Top ***!"<<std::endl;
+							bool rep = Est_voisin(gtmp,liste_voisin.at(id_Lv),Vertex_select.at(id_Vs));
+							if(rep == true){
+								tie(e1,found)=edge(vertex(Vertex_select.at(id_Vs),*gtmp),vertex(liste_voisin.at(id_Lv),*gtmp),*gtmp);
+								//std::cout<<"Top ***!!"<<std::endl;
+								//std::cout<<e1<<std::endl;
+								//std::cout<<"Top ***!!!"<<std::endl;
+								neigh_weight += (*gtmp)[e1]._weight;
+							}
+							//std::cout<<"Top ***!!!!"<<std::endl;
+						}
+						adjacent_weight.push_back(neigh_weight);
+					}
+
+					//std::cout<<"Top ****"<<std::endl;
+					max_weight = *std::max_element(adjacent_weight.begin(),adjacent_weight.end());
+					for(uint id = 0; id <adjacent_weight.size(); id++){
+						if(adjacent_weight.at(id) == max_weight){
+							index = id;
+							break;
+						}
+					}
+				}
+
+				//std::cout<<"Index "<<index<<std::endl;
+				//std::cout<<"Top *****"<<std::endl;
+				int best_vertexs = Vertex_select.at(index);
+				//std::cout<<"Index "<<best_vertexs<<std::endl;
+				Entiers *couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
+
+				/* Sélection  du sommet possedant un degrès maximum */
+				std::pair<double,int> couple1, couple2, best_min, best_max;
+				couple1.first = Degree(*gtmp,vertexs);
+				couple1.second = vertexs;
+				couple2.first = Degree(*gtmp,best_vertexs);
+				couple2.second = best_vertexs;
+				best_min = std::min(couple1,couple2);
+				best_max = std::max(couple1,couple2);
+				int vertex_delete = best_min.second; // Sommet d'index le plus grand (qui sera détruit)
+				//std::cout<<"sommet détruit : "<<(*gtmp)[vertex_delete]._index<<std::endl;
+				int vertex_save = best_max.second; // Sommet d'identifiant le plus petit (qui sera conservé)
+				//std::cout<<"sommet sauvé : "<<(*gtmp)[vertex_save]._index<<std::endl;
+
+				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
+				/*
+				 * On ajoute au tableau "couple" le couple de sommet à fusionner
+				 */
+				couple->push_back(vertex_save);
+				couple->push_back(vertex_delete);
+				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
+
+				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
+
+				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les sommets adjacents au "sommet sauvegardé"
+				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
+
+				/*
+				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
+				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
+				 * du processus]
+				 */
+    UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+    UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+						neigh_vertex_save.push_back(*neighbourIt);
+				}
+
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+						neigh_vertex_delete.push_back(*neighbourIt);
+				}
+
+				sort(neigh_vertex_save.begin(),neigh_vertex_save.end());
+				sort(neigh_vertex_delete.begin(),neigh_vertex_delete.end());
+
+				/*
+				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
+				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
+				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
+				 */
+				for(uint j=0;j<neigh_vertex_delete.size();j++){
+					if(In_tab_dichotomie(neigh_vertex_save,neigh_vertex_delete[j])==1){
+						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+					else
+					{
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+				}
+
+				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
+				/*
+				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
+				 */
+				Index_Vertex.at(Random_list_vertices.at(i))=-1;
+				Index_Vertex.at(best_vertexs)=-1;
+				val_cpt--;
+			}
+			else{
+				/*
+				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
+				 * alors on l'ajoute à la liste de correspondance des sommets et on
+				 * le verrouille
+				 */
+				//std::cout<<"Le sommet tiré est isolé "<<std::endl;
+				Entiers *couple = new Entiers();
+				couple->push_back(vertexs);
+				tableau_de_correspondance->push_back(couple);
+				Index_Vertex.at(Random_list_vertices.at(i))=-1;
+			}
+		}else{
+			//std::cout<<"Le sommet est bloqué "<<std::endl;
+			//std::cout<<" ça place est : "<<Random_list_vertices.at(i)<<" valeur : "<<Index_Vertex.at(Random_list_vertices.at(i))<<std::endl;
+		}
+
+		if(val_cpt == val_reduc){
+			//std::cout<<"Taille obtenue !"<<std::endl;
+			for(uint j=i+1; j < nbr_vertex; j++){
+				if(Index_Vertex.at(Random_list_vertices.at(j)) != -1){
+				Entiers *couple = new Entiers();
+				couple->push_back(vertexs);
+				tableau_de_correspondance->push_back(couple);}
+			}
+			break;
+		}
+	}
+
+	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
+
+	/*
+	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
+	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
+	 * des sommets
+	 */
+
+	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
+		remove_vertex(sommets_a_detruire[j],*gtmp);
+	}
+
+	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
+	liste_corr.push_back(tableau_de_correspondance);
+	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
+
+	if(val_cpt == val_reduc)
+		return true;
+	else
+		return false;
+
+}
+
+bool Est_voisin(UnorientedGraph *g, int vertex, int vertex_select)
+{
+    bool reponse = false;
+    UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex, *g);
+    for (; neighbourIt != neighbourEnd; ++neighbourIt){
+        if(*neighbourIt == vertex_select)
+            reponse = true;
+    }
+    return reponse;
+}
+
+bool contraction_Random_Maching(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr, int val_reduc, int &val_cpt){
+	UnorientedGraph *gtmp = new UnorientedGraph();
+	boost::copy_graph(*g, *gtmp);
+	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
+	edge_t e1,e2; // Iterateurs sur les arcs
+	bool found;
+	uint nbr_vertex = num_vertices(*gtmp);
+	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
+
+	/*
+	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
+	 * aléatoirement afin de simuler un tirage aléatoire
+	 */
+	Entiers Random_list_vertices = Random_Sort_Vector(nbr_vertex);
+
+	/*
+	 * Pour chaque sommet non verrouiller faire ....
+	 */
+	for(uint i=0; i<nbr_vertex; i++){
+		int vertexs = Random_list_vertices[i];
+		if(vertexs!=-1){
+			Entiers liste_voisin = Liste_adjacence(*gtmp,vertexs,Random_list_vertices); // Recherche des sommets adjacents au sommets  tiré
+			if(liste_voisin.size()!=0){
+				/*
+				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
+				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
+				 * le même poids, on selectionne le sommet d'identifiant le plus petit
+				 */
+				int tmp;
+				if(liste_voisin.size()==1)
+					tmp = 0;
+				else
+					tmp = rand_fini(0,liste_voisin.size()-1);
+
+				int best_vertexs = liste_voisin.at(tmp);
+
+				Entiers * couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
+				int vertex_delete = std::max(vertexs, best_vertexs); // Sommet d'indentifiant le plus grand (qui sera détruit)
+				int vertex_save = std::min(vertexs,best_vertexs); // Sommet d'identifiant le plus petit (qui sera conservé)
+
+				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
+				/*
+				 * On ajoute au tableau "couple" le couple de sommet à fusionner
+				 */
+				couple->push_back(vertex_save);
+				couple->push_back(vertex_delete);
+				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
+
+				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
+
+				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les somemts adjacents au "sommet sauvegardé"
+				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
+
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
+
+				/*
+				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
+				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
+				 * du processus]
+				 */
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_save.push_back(*neighbourIt);
+				}
+
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_delete.push_back(*neighbourIt);
+				}
+
+				/*
+				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
+				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
+				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
+				 */
+				for(uint j=0;j<neigh_vertex_delete.size();j++){
+					if(In_tab(neigh_vertex_save,neigh_vertex_delete[j])==1){
+						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+					else
+					{
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+				}
+
+				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
+				/*
+				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
+				 */
+				Random_list_vertices[i]=-1;
+				Random_list_vertices[recherche_val(Random_list_vertices,best_vertexs)]=-1;
+				val_cpt--;
+				// std::cout<<val_cpt<<std::endl;
+			}
+			else{
+				/*
+				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
+				 * alors on l'ajoute à la liste de correspondance des sommets et on
+				 * le verrouille
+				 */
+				Entiers *couple = new Entiers();
+				couple->push_back(Random_list_vertices.at(i));
+				tableau_de_correspondance->push_back(couple);
+				Random_list_vertices[i]=-1;
+			}
+		}
+		if(val_cpt == val_reduc){
+			for(uint j=i+1; j <nbr_vertex; j++){
+				if(Random_list_vertices[j] !=-1){
+				Entiers *couple = new Entiers();
+				couple->push_back(Random_list_vertices.at(j));
+				tableau_de_correspondance->push_back(couple);}
+			}
+			break;
+		}
+	}
+
+	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
+	//std::cout<<"\n"<<std::endl;
+	/*
+	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
+	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
+	 * des sommets
+	 */
+	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
+		//std::cout<<"Noeuds a supprimer : "<<sommets_a_detruire.at(j)<<std::endl;
+		remove_vertex(sommets_a_detruire[j],*gtmp);
+	}
+
+	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
+	liste_corr.push_back(tableau_de_correspondance);
+	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
+
+
+	if(val_cpt == val_reduc)
+		return true;
+	else
+		return false;
+
+}
+
+Entiers Liste_adjacence(UnorientedGraph &g, int vertexs,const Entiers &random_vertices){ // a revoir !!!!
+	Entiers liste_voisin;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs, g);
+	for (; neighbourIt != neighbourEnd; ++neighbourIt){
+		if(In_tab(random_vertices,*neighbourIt)==1)
+			liste_voisin.push_back(*neighbourIt);
+	}
+	return liste_voisin;
+}
+
+Entiers Liste_adjacence_tests(UnorientedGraph &g, int vertexs,const Entiers &Index_Vertex){ // a revoir !!!!
+	Entiers liste_voisin;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs, g);
+	for (; neighbourIt != neighbourEnd; ++neighbourIt){
+		if(Index_Vertex.at(*neighbourIt)!=-1)
+			liste_voisin.push_back(*neighbourIt);
+	}
+	return liste_voisin;
+}
+
+int rand_fini(int a, int b){
+	return rand()%(b-a)+a;
+}
+
+/**
+ * Fonction de recherche d'une valeur dans un tableau.
+ * @param tab
+ * @param val
+ * @return
+ */
+int recherche_val2(const std::vector<float> &tab,float val){
+	int cpt=0;
+	while(tab[cpt]!=val)
+		cpt++;
+	return cpt;
+}
+
+int recherche_val_double(const std::vector<double> &tab,double val){
+	int cpt=0;
+	while(tab[cpt]!=val)
+		cpt++;
+	return cpt;
+}
+
+int recherche_val(const Entiers &tab,int val){
+	int cpt=0;
+	while(tab[cpt]!=val)
+		cpt++;
+	return cpt;
+}
+/**
+ * @param tab
+ * @param i
+ * @return
+ */
+int dichotomie(const Entiers &tab, int i){
+
+	/* déclaration des variables locales à la fonction */
+	int id;  //indice de début
+	int ifin;  //indice de fin
+	int im;  //indice de "milieu"
+
+	/* initialisation de ces variables avant la boucle de recherche */
+	id = 0;  //intervalle de recherche compris entre 0...
+	ifin = tab.size();  //...et nbVal
+
+	/* boucle de recherche */
+	while ((ifin - id) > 1){
+		im = (id + ifin)/2;  //on détermine l'indice de milieu
+		if(tab[im] > i) ifin = im;  //si la valeur qui est à la case "im" est supérieure à la valeur recherchée, l'indice de fin "ifin" << devient >> l'indice de milieu, ainsi l'intervalle de recherche est restreint lors du prochain tour de boucle
+		else id = im;  //sinon l'indice de début << devient >> l'indice de milieu et l'intervalle est de la même façon restreint
+	}
+
+	/* test conditionnant la valeur que la fonction va renvoyer */
+	if (tab[id] == i) return id;  //si on a trouvé la bonne valeur, on retourne l'indice
+	else return -1;  //sinon on retourne -1
+
+}
+
+/**
+ * Fonction permettant de supprimer une case d'un tableau.
+ * @param tab une référence sur un tableau d'entiers
+ * @param i un indice dans tab
+ */
+void suprim_val(Entiers &tab,int i) {
+	tab.erase(tab.begin() + dichotomie(tab,i));
+}
+
+/**
+ * Détermine si une valeur se trouve dans un tableau.
+ * @param tab une référence sur un tableau d'entiers
+ * @param val une valeur
+ * @return true si la valeur a été trouvée, false sinon
+ */
+bool In_tab(const Entiers &tab, int val)
+{
+	for (uint i=0; i < tab.size(); i++)
+		if(tab[i]==val)
+			return true;
+	return false;
+}
+
+bool In_tab_dichotomie(const Entiers &tab, int val)
+{
+	if(dichotomie(tab,val)!=-1)
+		return true;
+	else
+		return false;
+}
+
+
+void Liste_Voisin(const Entiers &P,Entiers &tab,const UnorientedGraph &g)
+{
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+tie(neighbourIt, neighbourEnd) = adjacent_vertices(P.at(P.size()-1), g);
+	for (; neighbourIt != neighbourEnd; ++neighbourIt)
+	{
+		if((In_tab(tab,*neighbourIt) == false ) && (In_tab(P,*neighbourIt) == false ))
+			tab.push_back(*neighbourIt);
+	}
+}
+
+int Cout_coupe(Entiers P,int val, UnorientedGraph &g)
+{
+	int cpt=0;
+	P.push_back(val);
+	for(uint i=0;i<P.size();i++){
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(P[i], g);
+		for (; neighbourIt != neighbourEnd; ++neighbourIt){
+			if(In_tab(P,*neighbourIt)!=1){
+				cpt++;
+			}
+		}
+	}
+	return cpt;
+}
+
+double Cut_one_cluster(const Entiers &cluster, UnorientedGraph &g, std::string name)
+{
+	if(name=="norm"){
+		edge_t e1;
+		bool found;
+		double cpt=0.;
+		for(uint i=0;i<cluster.size();i++){
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i), g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				tie(e1,found)=edge(vertex(cluster[i],g),vertex(*neighbourIt,g),g);
+				if(In_tab(cluster,*neighbourIt)!=1){
+					cpt+=g[e1]._weight;
+				}
+			}
+		}
+		double deg = Cluster_Degree(g,cluster);
+		return cpt/deg;
+	}
+	else if(name == "cut"){
+		edge_t e1;
+		bool found;
+		double cpt=0.;
+		for(uint i=0;i<cluster.size();i++){
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i), g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				tie(e1,found)=edge(vertex(cluster.at(i),g),vertex(*neighbourIt,g),g);
+				if(In_tab(cluster,*neighbourIt)!=1){
+					cpt+=g[e1]._weight;
+				}
+			}
+		}
+		return cpt/2.;
+	}
+	else if(name == "ratio"){
+		edge_t e1;
+		bool found;
+		double cpt=0.;
+		for(uint i=0;i<cluster.size();i++){
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i), g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				tie(e1,found)=edge(vertex(cluster.at(i),g),vertex(*neighbourIt,g),g);
+				if(In_tab(cluster,*neighbourIt)!=1){
+					cpt+=g[e1]._weight;
+				}
+			}
+		}
+		double vol = Cluster_Weight(g,cluster);
+		return (cpt/2.)/vol;
+	}
+
+	/*Vérification de la formule : doute sur le /2.*/
+}
+
+double Cut_cluster(const EntiersEntiers &tab_cluster,UnorientedGraph &g,std::string name)
+{
+	double cpt=0.;
+	for(uint i=0;i<tab_cluster.size();i++){
+		cpt+=Cut_one_cluster(*tab_cluster[i],g,name);
+	}
+	return cpt;
+}
+
+double Cout_coupe_pond(Entiers P, int val, UnorientedGraph &g)
+{
+    edge_t e1;
+    bool found;
+    double cpt=0;
+
+    P.push_back(val);
+    for(uint i=0;i<P.size();i++){
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+        tie(neighbourIt, neighbourEnd) = adjacent_vertices(P[i], g);
+        for (; neighbourIt != neighbourEnd; ++neighbourIt){
+            tie(e1,found)=edge(vertex(P[i],g),vertex(*neighbourIt,g),g);
+            if(In_tab(P,*neighbourIt)!=1){
+                cpt+=g[e1]._weight;
+            }
+        }
+    }
+    return cpt;
+}
+
+
+int In_community_dichotomie(const EntiersEntiers &part, int val)
+{
+    for (uint i = 0; i < part.size() ; i++) {
+        if (In_tab_dichotomie(*part[i], val)) {
+            return i;
+        }
+    }
+    return -1;
+}
+
+double Degree(UnorientedGraph& g, int node)
+{
+    edge_t e1;
+    bool found;
+    double val = 0.;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(node, g);
+    for (; neighbourIt != neighbourEnd; ++neighbourIt) {
+        tie(e1, found) = edge(vertex(node, g), vertex(*neighbourIt, g), g);
+        val += g[e1]._weight;
+    }
+    return val;
+}
+
+double Cluster_Degree(UnorientedGraph &g , const Entiers &cluster)
+{
+    double val = 0.;
+
+    for(uint i = 0; i < cluster.size(); i++){
+        val += Degree(g, cluster.at(i));
+    }
+    return val;
+}
+
+double Cluster_Weight(UnorientedGraph &g , const Entiers &cluster)
+{
+    double val = 0.;
+
+    for(uint i = 0; i < cluster.size(); i++){
+        val += g[cluster.at(i)]._weight;;
+    }
+    return val;
+}
+
+void List_edge_partie(Entiers *Partie, OrientedGraph *go, Edges &edge_partie,
+                      OutputEdges &outputedgespartie){
+    edge_to e1;
+    //bool found;
+
+    for(uint i = 0; i < Partie->size(); i++) {
+OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
+        tie(neighbourIto, neighbourEndo) = adjacent_vertices(Partie->at(i),
+                                                             *go);
+        for (; neighbourIto != neighbourEndo; ++neighbourIto) {
+            if(In_tab_dichotomie(*Partie,*neighbourIto)) {
+                Edge new_edge;
+
+                new_edge.first = Partie->at(i);
+                new_edge.second = *neighbourIto;
+                edge_partie.push_back(new_edge);
+            } else {
+                Edge new_edge;
+
+                new_edge.first = Partie->at(i);
+                new_edge.second = *neighbourIto;
+                outputedgespartie.push_back(new_edge);
+            }
+        }
+    }
+}
+
+void Global_Neigh_community(UnorientedGraph *g,
+                            const EntiersEntiers &Partition,
+                            Entiers *community, int vertex, int comm_in)
+{
+    int comm;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex, *g);
+    for (; neighbourIt != neighbourEnd; ++neighbourIt){
+        comm = In_community_dichotomie(Partition, *neighbourIt);
+        if (In_tab(*community,comm) != 1 and comm != comm_in)
+            community->push_back(comm);
+    }
+}
+
+OrientedGraphs Graph_Partition(const EntiersEntiers& Partition,
+                               OrientedGraph *go,
+                               UnorientedGraph *g,
+                               OutputEdgeList &outputedgelist,
+                               InputEdgeList &inputedgelist,
+                               Connections &connections)
+{
+    OrientedGraphs graph_partie;
+    EntiersEntiers neigh_community;
+
+    for (uint i = 0; i < Partition.size();i++){
+        Edges edge_partie;
+        List_edge_partie(Partition.at(i),go,edge_partie,outputedgelist.at(i));
+        OrientedGraph graph;
+        std::vector<vertex_to> tab_vertex_to;
+        Entiers *community = new Entiers();
+
+        for (uint j = 0; j < Partition.at(i)->size(); j++) {
+            Global_Neigh_community(g, Partition, community,
+                                   Partition.at(i)->at(j),i);
+            vertex_to v = add_vertex(graph);
+
+            tab_vertex_to.push_back(v);
+            graph[v] = VertexProperties((*go)[Partition.at(i)->at(j)]);
+        }
+        neigh_community.push_back(community);
+
+        for(uint k = 0; k < edge_partie.size(); k++) {
+            add_edge(tab_vertex_to.at(recherche_val(*Partition.at(i),
+                                                    edge_partie.at(k).first)),
+                     tab_vertex_to.at(recherche_val(*Partition.at(i),
+                                                    edge_partie.at(k).second)),
+                     graph);
+        }
+        graph_partie.push_back(graph);
+    }
+
+    for (uint i = 0; i < neigh_community.size(); i++) {
+        InputEdges inputedges;
+
+        for (uint j = 0; j < neigh_community.at(i)->size(); j++) {
+            for (uint k = 0;
+                 k < outputedgelist.at(neigh_community.at(i)->at(j)).size();
+                 k++) {
+                if (In_tab_dichotomie(
+                        *Partition.at(i),
+                        outputedgelist.at(
+                            neigh_community.at(i)->at(j)).at(k).second))
+                    inputedges.push_back(
+                        outputedgelist.at(
+                            neigh_community.at(i)->at(j)).at(k));
+            }
+        }
+        inputedgelist.push_back(inputedges);
+    }
+
+    for (uint i = 0; i < outputedgelist.size(); i++){
+        Connection connec;
+
+        for(uint j = 0; j < outputedgelist.at(i).size(); j++){
+            Port port1;
+
+            port1.first = i + 1;
+            port1.second = outputedgelist.at(i).at(j).first;
+
+            Port port2;
+
+            port2.first = In_community_dichotomie(
+                Partition,outputedgelist.at(i).at(j).second) + 1;
+            port2.second = outputedgelist.at(i).at(j).second;
+
+            connec.first = port1;
+            connec.second = port2;
+
+            connections.push_back(connec);
+        }
+    }
+
+    for (EntiersEntiers::iterator it = neigh_community.begin();
+        it != neigh_community.end(); it++) {
+        delete *it;
+        *it = NULL;
+    }
+
+    return graph_partie;
+}
+
+double Best_Cut_cluster(EntiersEntiers &tab_cluster,Entiers *cluster1, Entiers *cluster2, int index_cluster1, UnorientedGraph &g,std::string name)
+{
+	tab_cluster.push_back(cluster2);
+
+	double cpt=0.;
+	for(int i=0;i<tab_cluster.size();i++){
+		if(i!=index_cluster1){
+		cpt+=Cut_one_cluster(*tab_cluster[i],g,name);
+		}
+	}
+	cpt+=Cut_one_cluster(*cluster1,g,name);
+	tab_cluster.pop_back();
+	return cpt;
+}
+
+double In_modularity(UnorientedGraph *g , const Entiers &cluster){
+	//property_map<UnorientedGraph,edge_weight_t>::type poids_arc=get(edge_weight_t(),g);
+	edge_t e1;
+	bool found;
+	int val=0;
+
+	for(uint i=0;i<cluster.size();i++){
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i),*g);
+		for (; neighbourIt != neighbourEnd; ++neighbourIt){
+			tie(e1,found)=edge(vertex(cluster[i],*g),vertex(*neighbourIt,*g),*g);
+			if(In_tab(cluster,*neighbourIt)==1)
+				val+=(*g)[e1]._weight;
+				//val+=get(poids_arc,e1);
+		}
+	}
+	return val/2.;
+}
+
+/**
+ *
+ * @param g
+ * @param cluster
+ * @return
+ */
+
+
+
+/**
+ *
+ * @param g
+ * @param part
+ * @return
+ */
+
+double Modularity(UnorientedGraph *g,const EntiersEntiers &part){
+  double q  = 0.;
+  int tmp=num_edges(*g);
+  for(uint i=0;i<part.size();i++){
+	  q+=In_modularity(g,*part.at(i))/tmp-(Cluster_Degree(*g,*part.at(i))/(2*tmp))*(Cluster_Degree(*g,*part.at(i))/(2*tmp));
+  	}
+
+  return q;
+}
+
+/**
+ *
+ * @param part
+ * @param val
+ * @return
+ */
+
+
+
+/**
+ * Fonction de calcul du gain de modularité de déplacement d'un sommet d'une communoté à une autre !!!!!
+ *  ajoute le sommet à part[val] et on calcul la nouvelle modularité
+ *  on prend la différence entre la modularité et la nouvouvelle !
+ * @param cur_mod
+ * @param val
+ * @param neight
+ * @param node_comm
+ * @param part
+ * @param g
+ */
+/*double Modularity_gain(double cur_mod , int val , int neight , int node_comm , EntiersEntiers part , UnorientedGraph &g) {
+	double q;
+	part[neight]->push_back(val);
+	std::sort(*part[neight]);
+	q=Modularity(g,part);
+
+	return q-cur_mod;
+}*/
+
+/**
+ * Fonction de calcul du gain de modularité de déplacement d'un sommet d'une communoté à une autre !!!!!
+ *  ajoute le sommet à part[val] et on calcul la nouvelle modularité
+ *  on prend la différence entre la modularité et la nouvouvelle !
+ * @param cur_mod
+ * @param tmp_community
+ * @param neight
+ * @param node_comm
+ * @param part
+ * @param g
+ */
+/*double Modularity_gain_phase_2(double cur_mod, Entiers tmp_community, int neight, int node_comm, EntiersEntiers part, UnorientedGraph &g) {
+	double q;
+	for (uint i=0;i<tmp_community.size();i++)
+		part[neight]->push_back(tmp_community[i]);
+	std::sort(*part[neight]);
+	q = Modularity(g,part);
+	return q - cur_mod;
+}*/
+
+/**
+ * Donne la liste des communautés voisines à celle contenant le sommet val.
+ * @param part
+ * @param val
+ * @param g
+ * @return
+ */
+/*Entiers Neight_community(const EntiersEntiers &part, int val , UnorientedGraph &g){
+	Entiers Neight;
+	tie(neighbourIt, neighbourEnd) = adjacent_vertices(val, g);
+	for (; neighbourIt != neighbourEnd; ++neighbourIt){
+		int tmp=In_community(part,*neighbourIt);
+		if(In_tab(Neight,tmp)!=1 && In_tab(*part[In_community(part,val)],*neighbourIt)!=1)
+			Neight.push_back(tmp);
+	}
+	std::sort(Neight);
+	return Neight;
+}*/
+
+/**
+ *
+ * @param part
+ * @param community
+ * @param g
+ * @return
+ */
+/*Entiers Part_Neight_community(const EntiersEntiers &part,int community, UnorientedGraph &g){
+	Entiers Neight;
+	for(uint i =0;i<part[community]->size();i++){
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(part[community]->at(i), g);
+		for (; neighbourIt != neighbourEnd; ++neighbourIt){
+			int tmp=In_community(part,*neighbourIt);
+			if(In_tab(Neight,tmp)!=1 && tmp!=community)
+				Neight.push_back(tmp);
+		}
+	}
+	std::sort(Neight);
+	return Neight;
+}*/
+
+void make_unoriented_graph(const OrientedGraph& og, UnorientedGraph& ug)
+{
+    std::vector < vertex_t > ug_vertex_list;
+    std::vector < vertex_t > og_vertex_list;
+
+    for (uint i = 0; i < num_vertices(og); ++i) {
+        ug_vertex_list.push_back(add_vertex(ug));
+    }
+
+    OrientedGraph::vertex_iterator it_og, end_og;
+    UnorientedGraph::vertex_iterator it_ug, end_ug;
+
+    tie(it_og, end_og) = vertices(og);
+    tie(it_ug, end_ug) = vertices(ug);
+    for (; it_og != end_og; ++it_og, ++it_ug) {
+        ug[*it_ug] = og[*it_og];
+        og_vertex_list.push_back(*it_og);
+    }
+
+    OrientedGraph::edge_iterator ite_og, ende_og;
+
+    tie(ite_og, ende_og) = edges(og);
+    for (; ite_og != ende_og; ++ite_og) {
+        boost::add_edge(source(*ite_og, og), target(*ite_og, og),
+                        og[*ite_og], ug);
+    }
+
+    // std::cout << "Oriented graph: " << std::endl;
+    // tie(it_og, end_og) = vertices(og);
+    // for (; it_og != end_og; ++it_og) {
+    //     OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
+
+    //     std::cout << og[*it_og]._index << " is connected with ";
+    //     tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_og, og);
+    //     for (; neighbour_it != neighbour_end; ++neighbour_it)
+    //         std::cout << og[*neighbour_it]._index << " ";
+    //     std::cout << " and weight = " << og[*it_og]._weight << std::endl;
+    // }
+    // std::cout << std::endl;
+
+    // std::cout << "Unoriented graph: " << std::endl;
+    // tie(it_ug, end_ug) = vertices(ug);
+    // for (; it_ug != end_ug; ++it_ug) {
+    //     UnorientedGraph::adjacency_iterator neighbour_it, neighbour_end;
+
+    //     std::cout << ug[*it_ug]._index << " is connected with ";
+    //     tie(neighbour_it, neighbour_end) = adjacent_vertices(*it_ug, ug);
+    //     for (; neighbour_it != neighbour_end; ++neighbour_it)
+    //         std::cout << ug[*neighbour_it]._index << " ";
+    //     std::cout << " and weight = " << ug[*it_ug]._weight << std::endl;
+    // }
+    // std::cout << std::endl;
+}
+
+void adjacence_ggp(int vertex, Entiers &sommets_adj, UnorientedGraph *g)
+{
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex, *g);
+    for (; neighbourIt != neighbourEnd; ++neighbourIt)
+    {
+        sommets_adj.push_back(*neighbourIt);
+    }
+
+}
+
+double modif_Cout_coupe(const Entiers &P, int val, double cut, UnorientedGraph *g)
+{
+    //std::cout<<"Cout de coupe initiale : "<<cut<<std::endl;
+    //std::cout<<"degré du sommet tiré : "<<Degree(*g,val)<<std::endl;
+    double cpt = 0.;
+    double new_cut;
+    bool found;
+	edge_t e1;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(val, *g);
+    for (; neighbourIt != neighbourEnd; neighbourIt++){
+        if(In_tab(P,*neighbourIt)==1){
+			tie(e1,found)=edge(vertex(val,*g),vertex(*neighbourIt,*g),*g);
+            cpt += (*g)[e1]._weight;
+        }
+    }
+    new_cut = cut + (Degree(*g,val) - 2*cpt);
+    return new_cut;
+}
+
+int decimal(int valeur){
+	int res;
+	switch(valeur){
+		case 0 ... 9 : res = 0;
+		break;
+		case 10 ... 99 : res = 1;
+		break;
+		case 100 ... 999 : res = 2;
+		break;
+		case 1000 ... 9999 : res = 3;
+		break;
+		case 10000 ... 99999 : res = 4;
+		break;
+		case 100000 ... 999999 : res = 5;
+		break;
+		case 1000000 ... 9999999 : res = 6;
+		break;
+		case 10000000 ... 99999999 : res = 7;
+		break;
+		case 100000000 ... 999999999 : res = 8;
+		break;
+	default :
+		// std::cout<<"L'interval n'est pas de taille suffisante"<<std::endl;
+		break;
+	}
+	return res;
+}
+
+void Graph_constructor_txt(const char* text, OrientedGraph * Og){
+
+	//Traitement initial
+	std::ifstream fichier (text, std::ios::in);
+	int lines = std::count(std::istreambuf_iterator<char>( fichier ),
+	std::istreambuf_iterator<char>(),'\n' );
+	//std::cout<<"Nombre de ligne : "<<lines<<std::endl;
+
+	fichier.seekg(0, std::ios::beg);
+	std::string caractere;
+	getline(fichier, caractere);
+	int caractere_size = caractere.size()+1;
+
+	fichier.seekg(0, std::ios::beg);
+	int nbr_vertices;
+	fichier >> nbr_vertices;
+	//std::cout << "Nombre de sommets : "<< nbr_vertices<< std::endl;
+
+	//Création des sommets
+
+	std::vector<vertex_to> vect_vertex;
+	for(int i =0; i<nbr_vertices; i++){
+		vertex_to v0 = boost::add_vertex(*Og);
+		vect_vertex.push_back(v0);
+	}
+
+	//Création des arcs
+	int deplacement_sup = 0;
+	for(int i = 0; i <(lines-nbr_vertices-1); i++){
+	fichier.seekg((8)*i+caractere_size+deplacement_sup, std::ios::beg);
+	int vertex_in, vertex_out;
+	double weight;
+	fichier >> vertex_in >> vertex_out >> weight ;
+	add_edge(vect_vertex.at(vertex_in), vect_vertex.at(vertex_out), EdgeProperties(weight), *Og);
+	//std::cout << vertex_in << " " << vertex_out << " " << weight << std::endl;
+	int tmp = decimal(vertex_in) + decimal(vertex_out) + decimal(floor(weight));
+	deplacement_sup += tmp;
+	}
+
+	//Pondération des sommets
+	int cpt =0;
+	for(int i = lines-nbr_vertices-1; i <lines-1; i++){
+            fichier.seekg((8)*(lines-nbr_vertices-1)+caractere_size+deplacement_sup, std::ios::beg);
+            double poids;
+            std::string txt;
+            fichier >> poids >> txt ;
+            int type;
+            if(txt == "NORMAL_PIXEL"){
+		type = 1;
+		// type = NORMAL_PIXEL;
+            }else{
+		type = 0;
+		// type = TOP_PIXEL;
+            }
+
+            // TODO !!!!
+            // (*Og)[vect_vertex.at(cpt)] = VertexProperties(cpt, poids, type);
+
+            //std::cout << poids << std::endl;
+            int tmp = decimal(floor(poids)) + 17;
+            deplacement_sup += tmp;
+            cpt++;
+	}
+
+	fichier.close();
+}
+
+void Text_generator_graph(const char *texte, OrientedGraph *go)
+{
+    bool found;
+    edge_to e1;
+    std::ofstream fichier (texte, std::ios::out);
+    OrientedGraph::vertex_iterator vertexIto, vertexEndo;
+    OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
+
+    fichier<<num_vertices(*go)<<std::endl;
+    tie(vertexIto, vertexEndo) = vertices(*go);
+    for (; vertexIto != vertexEndo; ++vertexIto) {
+    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
+                                                             *go);
+    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
+            tie(e1,found)=edge(vertex(*vertexIto,*go),vertex(*neighbourIto,*go),*go);
+            if(((*go)[e1]._weight - floor((*go)[e1]._weight)) == 0 ){
+                fichier<<(*go)[*vertexIto]._index<<" "<<(*go)[*neighbourIto]._index<<" "<<(*go)[e1]._weight<<".0"<<std::endl;
+            }else{
+                fichier<<(*go)[*vertexIto]._index<<" "<<(*go)[*neighbourIto]._index<<" "<<(*go)[e1]._weight<<std::endl;
+            }
+    	}
+    }
+    tie(vertexIto, vertexEndo) = vertices(*go);
+    for (; vertexIto != vertexEndo; ++vertexIto) {
+
+        // TODO !!!!
+
+// if(((*go)[*vertexIto]._weight - floor((*go)[*vertexIto]._weight)) == 0 & (*go)[*vertexIto]._type == 0 /*TOP_PIXEL*/){
+        //     fichier<<(*go)[*vertexIto]._weight<<".0"<<" "<<"TOP_PIXEL"<<"   "<<std::endl;
+        // } else if(((*go)[*vertexIto]._weight - floor((*go)[*vertexIto]._weight)) == 0 && (*go)[*vertexIto]._type == 1 /*NORMAL_PIXEL*/){
+        //     fichier<<(*go)[*vertexIto]._weight<<".0"<<" "<<"NORMAL_PIXEL"<<std::endl;
+        // } else if(((*go)[*vertexIto]._weight - floor((*go)[*vertexIto]._weight)) != 0 && (*go)[*vertexIto]._type == 0 /*TOP_PIXEL*/){
+        //     fichier<<(*go)[*vertexIto]._weight<<" "<<"TOP_PIXEL"<<std::endl;
+        // } else {
+        //     fichier<<(*go)[*vertexIto]._weight<<" "<<"NORMAL_PIXEL"<<std::endl;
+        // }
+
+    }
+
+    fichier.close();
+}
+
+double Diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition, int partie, int node, std::string name){
+	double Dif;
+	double Int = 0.;
+	double Ext = 0.;
+
+	edge_t e1;
+    bool found;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(node, *g);
+    for (; neighbourIt != neighbourEnd; ++neighbourIt){
+		tie(e1, found) = edge(vertex(node, *g), vertex(*neighbourIt, *g), *g);
+		if(In_tab_dichotomie(*Partition.at(partie),*neighbourIt) == 1){
+			Int+= (*g)[e1]._weight;
+		}else{
+			Ext+= (*g)[e1]._weight;
+		}
+    }
+
+	if(name == "ratio"){
+	    Int/=Cluster_Weight(*g,*Partition.at(partie));
+	    Ext/=Cluster_Weight(*g,*Partition.at(partie));
+	}
+
+	Dif = Ext - Int;
+	return Dif;
+}
+
+double Diff_cut_ratio_bissection(UnorientedGraph *g, Entiers *part, int node, std::string name){
+	double Ext = 0.;
+
+	edge_t e1;
+    bool found;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    tie(neighbourIt, neighbourEnd) = adjacent_vertices(node, *g);
+    for (; neighbourIt != neighbourEnd; ++neighbourIt){
+		tie(e1, found) = edge(vertex(node, *g), vertex(*neighbourIt, *g), *g);
+		if(In_tab_dichotomie(*part,*neighbourIt) != 1){
+			Ext+= (*g)[e1]._weight;
+		}
+    }
+
+	return Ext;
+}
+
+std::vector<std::vector<int>> Vector_diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition, std::string name){
+	std::vector<std::vector<int>> Diff_vector;
+
+	for(uint i = 0; i < Partition.size(); i++){
+		std::vector<std::pair<double,int>> D_vector;
+		for(uint j = 0; j < Partition.at(i)->size(); j++){
+			double gain_d = Diff_cut_ratio(g, Partition, i, Partition.at(i)->at(j), name);
+			//std::cout<<gain_d<<std::endl;
+			if(gain_d > 0){
+				std::pair<double, int> D;
+				D.first =  gain_d;
+				D.second = Partition.at(i)->at(j);
+				D_vector.push_back(D);
+			}
+		}
+		sort(D_vector.begin(),D_vector.end());
+		std::reverse(D_vector.begin(),D_vector.end());
+		std::vector<int> index_vector;
+		for(uint id = 0; id < D_vector.size(); id++){
+			index_vector.push_back(D_vector.at(id).second);
+		}
+		Diff_vector.push_back(index_vector);
+	}
+
+	/*std::cout<<"Tableau des différences "<<std::endl;
+	for(uint i = 0; i<Diff_vector.size(); i++){
+		std::cout<<"*"<<i<<"* ";
+		for(uint j = 0; j<Diff_vector.at(i).size(); j++){
+			std::cout<<Diff_vector.at(i).at(j)<<" ";
+		}
+		std::cout<<std::endl;
+	}*/
+
+	return Diff_vector;
+
+}
+
+std::vector<int> Vector_diff_cut_ratio_2(UnorientedGraph *g, const EntiersEntiers &Partition, std::string name){
+	std::vector<int> Diff_vector;
+	std::vector<std::pair<double,int>> D_vector;
+	for(uint i = 0; i < Partition.size(); i++){
+		for(uint j = 0; j < Partition.at(i)->size(); j++){
+			double gain_d = Diff_cut_ratio(g, Partition, i, Partition.at(i)->at(j), name);
+			//std::cout<<gain_d<<std::endl;
+			if(gain_d > 0){
+				std::pair<double, int> D;
+				D.first =  gain_d;
+				D.second = Partition.at(i)->at(j);
+				D_vector.push_back(D);
+			}
+		}
+	}
+	sort(D_vector.begin(),D_vector.end());
+	for(uint id = 0; id < D_vector.size(); id++){
+		Diff_vector.push_back(D_vector.at(id).second);
+	}
+
+	/*std::cout<<"Tableau des différences "<<std::endl;
+	for(uint i = 0; i<Diff_vector.size(); i++){
+		std::cout<<"*"<<i<<"* ";
+		for(uint j = 0; j<Diff_vector.at(i).size(); j++){
+			std::cout<<Diff_vector.at(i).at(j)<<" ";
+		}
+		std::cout<<std::endl;
+	}*/
+	/*for(uint j = 0; j<Diff_vector.size(); j++){
+		std::cout<<Diff_vector.at(j)<<" ";
+	}
+	std::cout<<std::endl;*/
+
+	return Diff_vector;
+
+}
+
+void Modif_vector_diff_cut_ratio_2(UnorientedGraph *g, const EntiersEntiers &Partition, std::vector<int> &Diff_vector, int node, std::string name){
+	std::vector<std::pair<double,int>> D_vector;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+	tie(neighbourIt, neighbourEnd) = adjacent_vertices(node, *g);
+	for (; neighbourIt != neighbourEnd; ++neighbourIt){
+		//std::cout<<"node : "<<node<<std::endl;
+		//std::cout<<"voisin : "<<*neighbourIt<<std::endl;
+		int neigh_ind = In_community_dichotomie(Partition, *neighbourIt);
+		//std::cout<<"dans  : "<<neigh_ind<<std::endl;
+		double gain_d = Diff_cut_ratio(g, Partition, neigh_ind, *neighbourIt, name);
+		//std::cout<<"gain_d : "<<gain_d<<std::endl;
+		if(gain_d > 0){
+			std::pair<double, int> D;
+			D.first =  gain_d;
+			D.second = *neighbourIt;
+			D_vector.push_back(D);
+		}
+		//suprim_val(Diff_vector,*neighbourIt);
+	}
+
+	if(D_vector.size() == 0){
+		Diff_vector.erase(Diff_vector.begin());
+		return;
+	}
+
+	//std::cout<<"**"<<std::endl;
+	sort(D_vector.begin(),D_vector.end());
+	for(uint id = 0; id < D_vector.size(); id++){
+		if(In_tab(Diff_vector,D_vector.at(id).second) != 1)
+			Diff_vector.push_back(D_vector.at(id).second);
+	}
+	//std::cout<<"***"<<std::endl;
+	Diff_vector.erase(Diff_vector.begin());
+	//std::cout<<"**!**"<<std::endl;
+
+	sort(Diff_vector.begin(),Diff_vector.end());
+
+	for(uint j = 0; j<Diff_vector.size(); j++){
+		// std::cout<<Diff_vector.at(j)<<" ";
+	}
+	//std::cout<<std::endl;
+}
+
+void Modif_vector_diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition, std::vector<std::vector<int>> &Diff_vector, int recalcul1, int recalcul2, std::string name){
+
+	std::vector<std::pair<double,int>> D_vector;
+	for(uint j = 0; j < Partition.at(recalcul1)->size(); j++){
+		double gain_d = Diff_cut_ratio(g, Partition, recalcul1, Partition.at(recalcul1)->at(j), name);
+		//std::cout<<gain_d<<std::endl;
+		if(gain_d > 0){
+			std::pair<double, int> D;
+			D.first =  gain_d;
+			D.second = Partition.at(recalcul1)->at(j);
+			D_vector.push_back(D);
+		}
+	}
+	sort(D_vector.begin(),D_vector.end());
+	std::reverse(D_vector.begin(),D_vector.end());
+	std::vector<int> index_vector;
+	for(uint id = 0; id < D_vector.size(); id++){
+		index_vector.push_back(D_vector.at(id).second);
+	}
+	Diff_vector.at(recalcul1) = index_vector;
+
+	std::vector<std::pair<double,int>> D_vector2;
+	for(uint j = 0; j < Partition.at(recalcul2)->size(); j++){
+		double gain_d = Diff_cut_ratio(g, Partition, recalcul2, Partition.at(recalcul2)->at(j), name);
+		//std::cout<<gain_d<<std::endl;
+		if(gain_d > 0){
+			std::pair<double, int> D;
+			D.first =  gain_d;
+			D.second = Partition.at(recalcul2)->at(j);
+			D_vector2.push_back(D);
+		}
+	}
+	sort(D_vector2.begin(),D_vector2.end());
+	std::reverse(D_vector2.begin(),D_vector2.end());
+	std::vector<int> index_vector2;
+	for(uint id = 0; id < D_vector2.size(); id++){
+		index_vector2.push_back(D_vector2.at(id).second);
+	}
+	Diff_vector.at(recalcul2) = index_vector2;
+
+	/*std::cout<<"Tableau des différences modifié "<<std::endl;
+	for(uint i = 0; i<Diff_vector.size(); i++){
+		std::cout<<"*"<<i<<"* ";
+		for(uint j = 0; j<Diff_vector.at(i).size(); j++){
+			std::cout<<Diff_vector.at(i).at(j)<<" ";
+		}
+		std::cout<<std::endl;
+	}*/
+
+}
+
+void Affinache_gain_diff(UnorientedGraph *g, EntiersEntiers &Partition, double &cut, std::string name, double poids_moy){
+	double old_cut = -1.;
+
+	while(old_cut != cut){
+		//std::cout<<"Boucle d'ammélioration "<<std::endl;
+		old_cut = cut;
+		sort(Partition.begin(), Partition.end(), myobject_taille);
+		/*for(uint i=0;i<Partition.size();i++){
+			std::cout<<Partition.at(i)->size()<<std::endl;
+		}*/
+		std::vector<std::vector<int>> diff_vector;
+		diff_vector = Vector_diff_cut_ratio(g, Partition, name);
+
+		/*for(uint i = 0; i<diff_vector.size(); i++){
+			std::cout<<diff_vector.at(i)<<std::endl;
+		}*/
+
+		for(uint indice = 0; indice < diff_vector.size(); indice ++){
+			if(diff_vector.at(indice).size() != 0 && Partition.at(indice)->size() >1){
+				//for(uint i = 0; i < diff_vector.at(indice).size(); i++){
+				int i =0;
+				while(diff_vector.at(indice).size() != 0 && Partition.at(indice)->size() >1 && i < diff_vector.at(indice).size() &&
+				Cluster_Weight(*g,*Partition.at(indice)) > (poids_moy-poids_moy/Partition.size())){
+					//std::cout<<"Sommet de départ : "<< (*g)[diff_vector.at(indice).at(i)]._index <<" dans "<<indice<<std::endl;
+					Entiers neigh_part;
+					neigh_part = Neigh_community(g, Partition, diff_vector.at(indice).at(i), indice);
+					int best_neigh_part = neigh_part.at(0);
+					double gain = -10000000.;
+					for(uint ind_neigh = 0; ind_neigh < neigh_part.size(); ind_neigh++){
+						double tmp_gain;
+						if(name == "ratio"){
+							tmp_gain = Gain_ratio(g,Partition,indice,neigh_part.at(ind_neigh),diff_vector.at(indice).at(i),cut);
+						}else{
+							double Int = 0.;
+							double Ext = 0.;
+							edge_t e1;
+						    bool found;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+						    tie(neighbourIt, neighbourEnd) = adjacent_vertices(diff_vector.at(indice).at(i), *g);
+						    for (; neighbourIt != neighbourEnd; ++neighbourIt){
+								tie(e1, found) = edge(vertex(diff_vector.at(indice).at(i), *g), vertex(*neighbourIt, *g), *g);
+								if(In_tab_dichotomie(*Partition.at(neigh_part.at(ind_neigh)),*neighbourIt) == 1){
+									Ext+= (*g)[e1]._weight;
+								}else if(In_tab_dichotomie(*Partition.at(indice),*neighbourIt) == 1){
+									Int+= (*g)[e1]._weight;
+								}
+						    }
+								tmp_gain = Ext - Int;
+						}
+
+					    if(tmp_gain > gain & tmp_gain > 0){
+							gain = tmp_gain;
+							best_neigh_part = neigh_part.at(ind_neigh);
+						}
+					}
+
+					//std::cout<<" Ensemble de déstination "<<best_neigh_part<<" gain de  : "<<gain<<std::endl;
+					if(gain > 0){
+						//std::cout<<"Modification"<<std::endl;
+						cut -= gain; /*Grosse modification a apporté de ce coté la*/
+						//std::cout<<"Ratio de coupe : "<<cut<<std::endl;
+						suprim_val(*Partition.at(indice),diff_vector.at(indice).at(i));
+						Partition.at(best_neigh_part)->push_back(diff_vector.at(indice).at(i));
+						sort(Partition.at(best_neigh_part)->begin(),Partition.at(best_neigh_part)->end());
+						//double cut2 = Cut_cluster(Partition,*g,"ratio");
+						//std::cout<<"Vrai ratio de coupe : "<<cut2<<std::endl;
+						Modif_vector_diff_cut_ratio(g,Partition,diff_vector,best_neigh_part,indice,name);
+						i = 0;
+					}else{
+						i++;
+					}
+				}
+			}
+		}
+		//std::cout<<cut<<std::endl;
+	}
+}
+
+void Affinache_gain_diff_2(UnorientedGraph *g, EntiersEntiers &Partition, double &cut, std::string name, double poids_moy){
+	double old_cut = -1.;
+
+	//while(old_cut != cut){
+		//std::cout<<"Boucle d'ammélioration "<<std::endl;
+		//old_cut = cut;
+		sort(Partition.begin(), Partition.end(), myobject_taille);
+		std::vector<int> diff_vector;
+		diff_vector = Vector_diff_cut_ratio_2(g, Partition, name);
+
+		//for(uint indice = 0; indice < diff_vector.size(); indice ++){
+		int indice = 0;
+		while(/*indice < diff_vector.size() &&*/ diff_vector.size() != 0){
+			int com = In_community_dichotomie(Partition,diff_vector.at(indice));
+			// std::cout<<" Ensemble de départ "<<com<<" sommet  : "<<diff_vector.at(indice)<<std::endl;
+			if(Partition.at(com)->size() >1 && Cluster_Weight(*g,*Partition.at(com)) > (poids_moy-poids_moy/Partition.size())){
+				Entiers neigh_part;
+				neigh_part = Neigh_community(g, Partition, diff_vector.at(indice), com);
+				int best_neigh_part = neigh_part.at(0);
+				double gain = -10000000.;
+				for(uint ind_neigh = 0; ind_neigh < neigh_part.size(); ind_neigh++){
+					double tmp_gain;
+					if(name == "ratio"){
+						tmp_gain = Gain_ratio(g,Partition,com,neigh_part.at(ind_neigh),diff_vector.at(indice),cut);
+					}else{
+						double Int = 0.;
+						double Ext = 0.;
+						edge_t e1;
+					    bool found;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+					    tie(neighbourIt, neighbourEnd) = adjacent_vertices(diff_vector.at(indice), *g);
+					    for (; neighbourIt != neighbourEnd; ++neighbourIt){
+							tie(e1, found) = edge(vertex(diff_vector.at(indice), *g), vertex(*neighbourIt, *g), *g);
+							if(In_tab_dichotomie(*Partition.at(neigh_part.at(ind_neigh)),*neighbourIt) == 1){
+								Ext+= (*g)[e1]._weight;
+							}else if(In_tab_dichotomie(*Partition.at(com),*neighbourIt) == 1){
+								Int+= (*g)[e1]._weight;
+							}
+					    }
+							tmp_gain = Ext - Int;
+					}
+
+				    if(tmp_gain > gain & tmp_gain > 0){
+						gain = tmp_gain;
+						best_neigh_part = neigh_part.at(ind_neigh);
+					}
+				}
+
+				// std::cout<<" Ensemble de déstination "<<best_neigh_part<<" gain de  : "<<gain<<std::endl;
+				if(gain > 0){
+					// std::cout<<"Modification"<<std::endl;
+					cut -= gain; /*Grosse modification a apporté de ce coté la*/
+					// std::cout<<"Ratio de coupe : "<<cut<<std::endl;
+					suprim_val(*Partition.at(com),diff_vector.at(indice));
+					Partition.at(best_neigh_part)->push_back(diff_vector.at(indice));
+					sort(Partition.at(best_neigh_part)->begin(),Partition.at(best_neigh_part)->end());
+					double cut2 = Cut_cluster(Partition,*g,"ratio");
+					// std::cout<<"Vrai ratio de coupe : "<<cut2<<std::endl;
+					//Modif_vector_diff_cut_ratio_2(g,Partition,diff_vector,diff_vector.at(indice),name);
+					//indice = 0;
+					diff_vector.erase(diff_vector.begin());
+				}else{
+					diff_vector.erase(diff_vector.begin());
+				}
+			}
+		}
+		//std::cout<<cut<<std::endl;
+//	}
+}
+
+double Gain_ratio(UnorientedGraph *g,const EntiersEntiers &Partition, int in, int out, int node, double ratio){
+	double new_ratio = ratio;
+	double poids_in = Cluster_Weight(*g,*Partition.at(in));
+	double poids_out = Cluster_Weight(*g,*Partition.at(out));
+	double tmp_poids_in = poids_in - (*g)[node]._weight;
+	double tmp_poids_out = poids_out + (*g)[node]._weight;
+	//std::cout<<"tmp_poids_in "<< tmp_poids_in <<std::endl;
+	//std::cout<<"tmp_poids_out "<< tmp_poids_out <<std::endl;
+
+	double cut_in = 0.;
+	double cut_out = 0.;
+	double tmp_cut_in = 0.;
+	double tmp_cut_out = 0.;
+
+	edge_t e1;
+	bool found;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+	for(uint i = 0; i < Partition.at(in)->size(); i++){
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(Partition.at(in)->at(i), *g);
+		for (; neighbourIt != neighbourEnd; ++neighbourIt){
+			tie(e1,found)=edge(vertex(Partition.at(in)->at(i),*g),vertex(*neighbourIt,*g),*g);
+			if(In_tab_dichotomie(*Partition.at(in),*neighbourIt) != 1){
+				if(Partition.at(in)->at(i) != node){
+					tmp_cut_in += (*g)[e1]._weight;
+				}
+				cut_in += (*g)[e1]._weight;
+			}else if(*neighbourIt == node){
+				tmp_cut_in += (*g)[e1]._weight;
+			}
+		}
+	}
+
+	for(uint i = 0; i < Partition.at(out)->size(); i++){
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(Partition.at(out)->at(i), *g);
+		for (; neighbourIt != neighbourEnd; ++neighbourIt){
+			tie(e1,found)=edge(vertex(Partition.at(out)->at(i),*g),vertex(*neighbourIt,*g),*g);
+			if(In_tab_dichotomie(*Partition.at(out),*neighbourIt) != 1){
+				if(*neighbourIt != node){
+					tmp_cut_out += (*g)[e1]._weight;
+				}
+				cut_out += (*g)[e1]._weight;
+			}
+		}
+	}
+	tie(neighbourIt, neighbourEnd) = adjacent_vertices(node, *g);
+	for (; neighbourIt != neighbourEnd; ++neighbourIt){
+		tie(e1,found)=edge(vertex(node,*g),vertex(*neighbourIt,*g),*g);
+		if(In_tab_dichotomie(*Partition.at(out),*neighbourIt) != 1){
+			tmp_cut_out += (*g)[e1]._weight;
+		}
+	}
+
+	//std::cout<<"tmp_cut_in "<< tmp_cut_in/2. <<std::endl;
+	//std::cout<<"tmp_cut_out "<< tmp_cut_out/2. <<std::endl;
+	new_ratio -= cut_in/2./poids_in;
+	new_ratio -= cut_out/2./poids_out;
+	new_ratio += tmp_cut_in/2./tmp_poids_in;
+	new_ratio += tmp_cut_out/2./tmp_poids_out;
+
+	//std::cout<<"Nouveau ratio : " <<new_ratio<<std::endl;
+	return ratio - new_ratio;
+
+}
+
+double Modif_ratio_cut(UnorientedGraph *g,Entiers *Ss, Entiers *Sd, int node, double ratio){/*Revoir cette fonction, modification psa forcement nécéssaire, plus simple !!!*/
+	double new_ratio;
+	double poids_in = Cluster_Weight(*g,*Ss);
+	double poids_out = Cluster_Weight(*g,*Sd);
+	double tmp_poids_in = poids_in - (*g)[node]._weight;
+	double tmp_poids_out = poids_out + (*g)[node]._weight;
+	//std::cout<<"tmp_poids_in "<< tmp_poids_in <<std::endl;
+	//std::cout<<"tmp_poids_out "<< tmp_poids_out <<std::endl;
+
+	double new_cut = 0.;
+	//double new_cut_out = 0.;
+	//double tmp_cut_in = 0.;
+	//double tmp_cut_out = 0.;
+
+	edge_t e1;
+	bool found;
+
+	for(uint i = 0; i < Ss->size(); i++){
+		if(Ss->at(i) != node){
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(Ss->at(i), *g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				tie(e1,found)=edge(vertex(Ss->at(i),*g),vertex(*neighbourIt,*g),*g);
+				if(In_tab_dichotomie(*Ss,*neighbourIt) != 1){
+					new_cut += (*g)[e1]._weight;
+				}else if(*neighbourIt == node){
+					new_cut += (*g)[e1]._weight;
+				}
+			}
+		}
+	}
+
+	/*for(uint i = 0; i < Sd->size(); i++){
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(Sd->at(i), *g);
+		for (; neighbourIt != neighbourEnd; ++neighbourIt){
+			tie(e1,found)=edge(vertex(Sd->at(i),*g),vertex(*neighbourIt,*g),*g);
+			if(In_tab(*Sd,*neighbourIt) != 1){
+				if(*neighbourIt != node){
+					tmp_cut_out += (*g)[e1]._weight;
+				}
+				cut_out += (*g)[e1]._weight;
+			}
+		}
+	}
+	tie(neighbourIt, neighbourEnd) = adjacent_vertices(node, *g);
+	for (; neighbourIt != neighbourEnd; ++neighbourIt){
+		tie(e1,found)=edge(vertex(node,*g),vertex(*neighbourIt,*g),*g);
+		if(In_tab(*Sd,*neighbourIt) != 1){
+			tmp_cut_out += (*g)[e1]._weight;
+		}
+	}*/
+
+	//std::cout<<"tmp_cut_in "<< tmp_cut_in/2. <<std::endl;
+	//std::cout<<"tmp_cut_out "<< tmp_cut_out/2. <<std::endl;
+	new_ratio = new_cut/2./tmp_poids_in + new_cut/2./tmp_poids_out;
+	/*new_ratio -= cut_out/2./poids_out;
+	new_ratio += tmp_cut_in/2./tmp_poids_in;
+	new_ratio += tmp_cut_out/2./tmp_poids_out;*/
+
+	//std::cout<<"Nouveau ratio : " <<new_ratio<<std::endl;
+	return new_ratio;
+}
+
+EntiersEntiers Spectral_Partition(const char* text){
+	//Traitement initial
+	EntiersEntiers Partition;
+	std::ifstream fichier (text, std::ios::in);
+	if(fichier){
+		int lines = std::count(std::istreambuf_iterator<char>( fichier ),
+		std::istreambuf_iterator<char>(),'\n' );
+		// std::cout<<"Nombre de ligne : "<<lines<<std::endl;
+		/*** Récupération du dernier caractère ***/
+
+		/*** Création des paramétres contenant les informations ***/
+
+		int nmax_vertex;
+		fichier.seekg(0, std::ios::beg);
+		fichier >> nmax_vertex;
+		// std::cout<<"nmax_vertex : "<<nmax_vertex<<std::endl;
+		int nmax_size = decimal(nmax_vertex) + 1;
+
+		/*** Récupération des informations ***/
+		int cpt = 1;
+		int length;
+		fichier.seekg(nmax_size, std::ios::beg);
+		while(cpt < lines){
+		Entiers *part = new Entiers();
+		for(uint i =0; i<nmax_vertex; i++){
+		 	int edge;
+			fichier >> edge;
+			if(edge != -1)
+				part->push_back(edge);
+		}
+		Partition.push_back(part);
+		length = fichier.tellg();
+		fichier.seekg(length+1, std::ios::beg);
+		cpt++;
+		}
+	}else{
+		// std::cerr << "Impossible d'ouvrir le fichier dans Spectral_Partition !" << std::endl;
+	}
+
+	return(Partition);
+}
+
+void Adjacent_Matrix_Txt(UnorientedGraph *g, const char* text)
+{
+    std::ofstream GRAPH4 (text, std::ios::out);
+    if(GRAPH4){
+        UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+        tie(vertexIt, vertexEnd) = vertices(*g);
+        edge_t e1;
+        bool found;
+
+        for (; vertexIt != vertexEnd; ++vertexIt) {
+            int cpt = 0;
+            UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+            tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
+                                                               *g);
+            for(int i = cpt; i<num_vertices(*g); i++){
+                if(i == *neighbourIt){
+                    tie(e1,found)=edge(vertex(*vertexIt,*g),vertex(*neighbourIt,*g),*g);
+                    GRAPH4<<(*g)[e1]._weight<<" ";
+                    cpt = *neighbourIt +1;
+                    ++neighbourIt;
+                    if(*neighbourIt == *neighbourEnd){
+                        for(int j = cpt; j<num_vertices(*g); j++)
+                            GRAPH4<<0<<" ";
+                        break;
+                    }
+                }else{
+                    GRAPH4<<0<<" ";
+                }
+            }
+            GRAPH4<<std::endl;
+        }
+
+        GRAPH4.close();
+    } //else
+        // std::cerr << "Impossible d'ouvrir le fichier dans Adjacent_Matrix_Txt !" << std::endl;
+}
+
+void Weight_Matrix_Txt(UnorientedGraph *g, const char* text)
+{
+    std::ofstream GRAPH4 (text, std::ios::out);
+
+    if(GRAPH4){
+        for (int i =0 ; i<num_vertices(*g); i++) {
+            GRAPH4<<(*g)[i]._weight<<" ";
+        }
+
+        GRAPH4.close();
+    } // else
+        // std::cerr << "Impossible d'ouvrir le fichier dans Weight_Matrix_Txt !" << std::endl;
+}
+
+void Plot_OrientedGraph(OrientedGraph *go, const char* text)
+{
+    edge_to e1;
+    bool found;
+    OrientedGraph::vertex_iterator vertexIto, vertexEndo;
+    OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
+
+
+    std::ofstream fichier2 (text, std::ios::out);
+    fichier2<<"digraph G {"<<std::endl;
+    tie(vertexIto, vertexEndo) = vertices(*go);
+    for (; vertexIto != vertexEndo; ++vertexIto) {
+    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
+                                                             *go);
+    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
+            tie(e1,found)=edge(vertex(*vertexIto,*go),
+                               vertex(*neighbourIto,*go),*go);
+            fichier2<<(*go)[*vertexIto]._index<<" -> "
+                    <<(*go)[*neighbourIto]._index<<" [label="
+                    <<(*go)[e1]._weight
+                    <<", fontsize=10, fontcolor= blue];"<<std::endl;
+    	}
+    }
+    fichier2<<"}";
+    fichier2.close();
+}
+
+void Plot_UnorientedGraph(UnorientedGraph *g, const char* text){
+	edge_t e1;
+	bool found;
+
+	std::ofstream GRAPH2 (text, std::ios::out);
+	GRAPH2<<"graph G {"<<std::endl;
+UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+	tie(vertexIt, vertexEnd) = vertices(*g);
+	for (; vertexIt != vertexEnd; ++vertexIt) {
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,*g);
+		for (; neighbourIt != neighbourEnd; ++neighbourIt){
+			if((*g)[*neighbourIt]._index>(*g)[*vertexIt]._index){
+				tie(e1,found)=edge(vertex(*vertexIt,*g),vertex(*neighbourIt,*g),*g);
+				GRAPH2<<(*g)[*vertexIt]._index<<" -- "<<(*g)[*neighbourIt]._index<<" [label="<<(*g)[e1]._weight<<", fontsize=10, fontcolor= blue];"<<std::endl;
+			}
+		}
+	}
+
+	GRAPH2<<"}";
+	GRAPH2.close();
+}
+
+void Plot_UnorientedGraph_All(UnorientedGraph *g, const EntiersEntiers &Partition, const char* text, bool Color){
+	edge_t e1;
+	bool found;
+
+	if(Partition.size()<17){
+		std::ofstream GRAPH2 (text, std::ios::out);
+		GRAPH2<<"graph G {"<<std::endl;
+UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+		tie(vertexIt, vertexEnd) = vertices(*g);
+		for (; vertexIt != vertexEnd; ++vertexIt) {
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,*g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				if((*g)[*neighbourIt]._index>(*g)[*vertexIt]._index){
+					tie(e1,found)=edge(vertex(*vertexIt,*g),vertex(*neighbourIt,*g),*g);
+					GRAPH2<<(*g)[*vertexIt]._index<<" -- "<<(*g)[*neighbourIt]._index<<" [label="<<(*g)[e1]._weight<<", fontsize=10, fontcolor= blue];"<<std::endl;}
+			}
+		}
+
+		if(Color == true){
+			std::vector<std::string> color;
+			color.push_back(", color=blue2, fontcolor=blue2];");
+			color.push_back(", color=red, fontcolor=red];");
+			color.push_back(", color=green, fontcolor=green];");
+			color.push_back(", color=turquoise, fontcolor=turquoise];");
+			color.push_back(", color=saddlebrown, fontcolor=saddlebrown];");
+			color.push_back(", color=indigo, fontcolor=indigo];");
+			color.push_back(", color=yellow, fontcolor=yellow2];");
+			color.push_back(", color=orange, fontcolor=orange];");
+			color.push_back(", color=olivedrab, fontcolor=olivedrab];");
+			color.push_back(", color=gold, fontcolor=gold];");
+			color.push_back(", color=slateblue2, fontcolor=slateblue2];");
+			color.push_back(", color=dimgrey, fontcolor=dimgrey];");
+			color.push_back(", color=cyan, fontcolor=cyan];");
+			color.push_back(", color=purple1, fontcolor=purpule1];");
+			color.push_back(", color=crimson, fontcolor=crimson];");
+			color.push_back(", color=black, fontcolor=black];");
+			for(uint k=0; k<Partition.size(); k++){
+				for(uint t=0; t<Partition.at(k)->size(); t++)
+				{
+					GRAPH2<<(*g)[Partition.at(k)->at(t)]._index<<" [label="<<(*g)[Partition.at(k)->at(t)]._weight<<color.at(k)<<std::endl;
+				}
+			}
+		}else{
+			for(uint k=0; k<num_vertices(*g); k++){
+				GRAPH2<<(*g)[k]._index<<" [label="<<(*g)[k]._index<<", weight="<<(*g)[k]._weight<<"];"<<std::endl;
+			}
+		}
+
+		GRAPH2<<"}";
+		GRAPH2.close();
+	}else{
+		// std::cout<<"Error : Le nombre de couleur est insuffisant pour réaliser l'affichange"<<std::endl;
+	}
+}
+
+void Plot_OrientedGraph_All(OrientedGraph *go, const EntiersEntiers &Partition, const char* text, bool Color){
+	edge_to e1;
+	bool found;
+
+	if(Partition.size()<17){
+		std::vector<std::string> color;
+		color.push_back("[color=blue2, fontcolor=blue2];");
+		color.push_back("[color=red, fontcolor=red];");
+		color.push_back("[color=green, fontcolor=green];");
+		color.push_back("[color=turquoise, fontcolor=turquoise];");
+		color.push_back("[color=saddlebrown, fontcolor=saddlebrown];");
+		color.push_back("[color=indigo, fontcolor=indigo];");
+		color.push_back("[color=yellow, fontcolor=yellow2];");
+		color.push_back("[color=orange, fontcolor=orange];");
+		color.push_back("[color=olivedrab, fontcolor=olivedrab];");
+		color.push_back("[color=gold, fontcolor=gold];");
+		color.push_back("[color=slateblue2, fontcolor=slateblue2];");
+		color.push_back("[color=dimgrey, fontcolor=dimgrey];");
+		color.push_back("[color=cyan, fontcolor=cyan];");
+		color.push_back("[color=purple1, fontcolor=purpule1];");
+		color.push_back("[color=crimson, fontcolor=crimson];");
+		color.push_back("[color=black, fontcolor=black];");
+
+		std::ofstream fichier2 (text, std::ios::out);
+	    fichier2<<"digraph G {"<<std::endl;
+OrientedGraph::vertex_iterator vertexIto, vertexEndo;
+OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
+	    tie(vertexIto, vertexEndo) = vertices(*go);
+	    for (; vertexIto != vertexEndo; ++vertexIto) {
+	    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
+	    			*go);
+	    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
+					tie(e1,found)=edge(vertex(*vertexIto,*go),vertex(*neighbourIto,*go),*go);
+					fichier2<<(*go)[*vertexIto]._index<<" -> "<<(*go)[*neighbourIto]._index<<" [label="<<(*go)[e1]._weight<<", fontsize=10, fontcolor= blue];"<<std::endl;
+	    	}
+		}
+
+	    if(Color == true){
+			for(uint k=0; k<Partition.size(); k++){
+				for(uint j=0; j<Partition.at(k)->size(); j++)
+				{
+					fichier2<<Partition.at(k)->at(j)<<color.at(k)<<std::endl;
+				}
+			}
+		}
+
+		fichier2<<"}";
+		fichier2.close();
+
+	}else{
+		// std::cout<<"Error : Le nombre de couleur est insuffisant pour réaliser l'affichange"<<std::endl;
+	}
+}
+
+
+void Affichage_OrientedGraph(OrientedGraph *go)
+{
+/*    OrientedGraph::vertex_iterator vertexIto, vertexEndo;
+    OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
+
+    tie(vertexIto, vertexEndo) = vertices(*go);
+    for (; vertexIto != vertexEndo; ++vertexIto) {
+    	std::cout<<(*go)[*vertexIto]._index<<" -> ";
+    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
+                                                             *go);
+    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
+            std::cout<<(*go)[*neighbourIto]._index<<" ";
+    	}
+    	std::cout<<std::endl;
+    }
+    std::cout<<std::endl; */
+}
+
+void Affichage_UnorientedGraph(UnorientedGraph *g)
+{
+/*    UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+    UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+    tie(vertexIt, vertexEnd) = vertices(*g);
+    for (; vertexIt != vertexEnd; ++vertexIt) {
+    	std::cout<<(*g)[*vertexIt]._index<<" -> ";
+    	tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
+                                                           *g);
+    	for (; neighbourIt != neighbourEnd; ++neighbourIt){
+            std::cout<<(*g)[*neighbourIt]._index<<" ";
+    	}
+    	std::cout<<std::endl;
+    }
+    std::cout<<std::endl; */
+}
+
+double Total_weight_edges(UnorientedGraph *g){
+	double Sum_weight_edges = 0.;
+	edge_t e1;
+	bool found;
+
+UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+	tie(vertexIt, vertexEnd) = vertices(*g);
+	for (; vertexIt != vertexEnd; ++vertexIt) {
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,*g);
+		for (; neighbourIt != neighbourEnd; ++neighbourIt){
+			if((*g)[*neighbourIt]._index>(*g)[*vertexIt]._index){
+				tie(e1,found)=edge(vertex(*vertexIt,*g),vertex(*neighbourIt,*g),*g);
+				Sum_weight_edges += (*g)[e1]._weight;
+				}
+		}
+	}
+
+	return Sum_weight_edges;
+}
+
+void Merge_Boost_Graph(OrientedGraph *go1, OrientedGraph *go2, std::vector<std::pair<int,int>> &connection, std::vector<double> &connection_weight){
+	edge_to e1;
+	bool found;
+
+	int nbr_go1 = num_vertices(*go1);
+	int nbr_go2 = num_vertices(*go2);
+
+OrientedGraph::vertex_iterator vertexIto, vertexEndo;
+OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
+
+/*** Fusion ***/
+	if(nbr_go1 >= nbr_go2){
+		tie(vertexIto, vertexEndo) = vertices(*go2);
+		for (; vertexIto != vertexEndo; ++vertexIto){
+			vertex_to v0 = boost::add_vertex(*go1);
+			(*go1)[v0] = VertexProperties((*go2)[*vertexIto]);
+		}
+
+		tie(vertexIto, vertexEndo) = vertices(*go2);
+		for (; vertexIto != vertexEndo; ++vertexIto){
+			tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,*go2);
+			for (; neighbourIto != neighbourEndo; ++neighbourIto){
+				tie(e1,found)=edge(vertex(*vertexIto,*go2),vertex(*neighbourIto,*go2),*go2);
+				add_edge(*vertexIto + nbr_go1, *neighbourIto + nbr_go1, (*go2)[e1]._weight, *go1);
+			}
+		}
+
+		/*** Connection ***/
+		/* Fonctionne si l'ordre de nomation respecte l'ordre boost sinon possibilité d'identification par nom*/
+		for(uint i = 0; i < connection.size(); i++){
+			add_edge(connection.at(i).first, connection.at(i).second, connection_weight.at(i) , *go1);
+		}
+
+	}else{
+		tie(vertexIto, vertexEndo) = vertices(*go1);
+		for (; vertexIto != vertexEndo; ++vertexIto){
+			vertex_to v0 = boost::add_vertex(*go2);
+			(*go2)[v0] = VertexProperties((*go1)[*vertexIto]);
+		}
+
+		tie(vertexIto, vertexEndo) = vertices(*go1);
+		for (; vertexIto != vertexEndo; ++vertexIto){
+			tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,*go1);
+			for (; neighbourIto != neighbourEndo; ++neighbourIto){
+				tie(e1,found)=edge(vertex(*vertexIto,*go1),vertex(*neighbourIto,*go1),*go1);
+				add_edge(*vertexIto + nbr_go2, *neighbourIto + nbr_go2, (*go1)[e1]._weight, *go2);
+			}
+		}
+
+		/*** Connection ***/
+		/* Fonctionne si l'ordre de nomation respecte l'ordre boost sinon possibilité d'identification par nom*/
+		for(uint i = 0; i < connection.size(); i++){
+			add_edge(connection.at(i).first, connection.at(i).second, connection_weight.at(i) , *go2);
+		}
+
+	}
+
+}
+
+Entiers Random_Sort_Vector(uint size){
+
+	Entiers random_order;
+	for (uint i = 0 ; i<  size ; i++)
+		random_order.push_back(i);
+	for (uint j=0 ; j < random_order.size()-1 ; j++) {
+		int rand_pos = rand()%(size-j)+j;
+		int tmp      = random_order.at(j);
+		random_order.at(j) = random_order.at(rand_pos);
+		random_order.at(rand_pos) = tmp;
+	}
+
+	return random_order;
+}
+
+Entiers Random_Sort_Vector2(uint min, uint size){
+
+	Entiers random_order;
+	for (uint i = min ; i<  size ; i++)
+		random_order.push_back(i);
+	for (uint j = 0 ; j < random_order.size()-1 ; j++) {
+		int rand_pos = rand()%(random_order.size()-j)+j;
+		int tmp      = random_order.at(j);
+		random_order.at(j) = random_order.at(rand_pos);
+		random_order.at(rand_pos) = tmp;
+	}
+
+	return random_order;
+}
+
+double distance_t(std::pair<double,double> x, std::pair<double,double> y)
+{
+	double total = (x.first - y.first) * (x.first - y.first) ;
+	double diff2 = (x.second - y.second) * (x.second - y.second);
+	total +=  diff2;
+
+	return sqrt(total);
+}
+
+void simple_graph(UnorientedGraph *g)
+{
+	edge_t e1;
+    bool found;
+
+UnorientedGraph::vertex_iterator vertexIt, vertexEnd;
+UnorientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+tie(vertexIt, vertexEnd) = vertices(*g);
+	for (; vertexIt != vertexEnd; ++vertexIt) {
+		tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,*g);
+
+		std::vector<uint> neight;
+		for (; neighbourIt != neighbourEnd; ++neighbourIt)
+			neight.push_back(*neighbourIt);
+		neight.push_back(-2);
+		sort(neight.begin(), neight.end());
+
+		int tmp = -1;
+		uint cpt = 1;
+		double wi = 0.;
+
+		for (uint i = 0; i < neight.size(); i++)
+		{
+			if(neight.at(i) > *vertexIt && *vertexIt != num_vertices(*g) - 1)
+			{
+				if(i != neight.size()-1)
+				{
+					tie(e1, found) = edge(vertex(*vertexIt, *g), vertex(neight.at(i), *g), *g);
+					if(tmp == neight.at(i))
+					{
+						wi += (*g)[e1]._weight;
+						cpt++;
+					}
+					else if(tmp != neight.at(i) & cpt != 1.)
+					{
+						remove_edge(*vertexIt,neight.at(i-1),*g);
+						add_edge(*vertexIt, neight.at(i-1), wi, *g);
+						wi = (*g)[e1]._weight;
+						cpt = 1;
+						tmp = neight.at(i);
+					}
+					else
+					{
+						wi = (*g)[e1]._weight;
+						cpt = 1.;
+						tmp = neight.at(i);
+					}
+				}
+				else
+				{
+					remove_edge(*vertexIt,neight.at(i-1),*g);
+					add_edge(*vertexIt, neight.at(i-1), wi, *g);
+				}
+			}
+		}
+	}
+}
+
+
 } } } // namespace paradevs tests boost_graph
 
 #endif

+ 1 - 0
src/tests/boost_graph/tests.cpp

@@ -29,6 +29,7 @@
 #include <paradevs/common/RootCoordinator.hpp>
 
 #include <tests/boost_graph/models.hpp>
+#include <tests/boost_graph/graph_defs.hpp>
 #include <tests/boost_graph/graph_builder.hpp>
 #include <tests/boost_graph/graph_generator.hpp>
 #include <tests/boost_graph/graph_manager.hpp>

+ 4 - 2
src/tests/mpi/CMakeLists.txt

@@ -18,9 +18,11 @@ LINK_DIRECTORIES(
 #  ${Boost_TIMER_LIBRARY}
 #  ${MPI_CXX_LIBRARIES})
 
-ADD_EXECUTABLE(pdevs-mpi-main graph_manager.hpp main.cpp)
+ADD_EXECUTABLE(pdevs-mpi-main graph_manager.hpp main.cpp
+  ../boost_graph/partitioning/utils.hpp ../boost_graph/partitioning/gggp.hpp
+  ../boost_graph/partitioning/graph_build.hpp)
 
-TARGET_LINK_LIBRARIES(pdevs-mpi-main partitioning
+TARGET_LINK_LIBRARIES(pdevs-mpi-main
   ${Boost_SERIALIZATION_LIBRARY}
   ${Boost_MPI_LIBRARY}
   ${MPI_CXX_LIBRARIES})

+ 4 - 2
src/tests/multithreading/CMakeLists.txt

@@ -19,9 +19,11 @@ TARGET_LINK_LIBRARIES(pdevs-multithreading-tests
 ADD_EXECUTABLE(pdevs-multithreading-main graph_manager.hpp main.cpp
   ../boost_graph/graph_builder.hpp ../boost_graph/graph_generator.hpp
   ../boost_graph/graph_defs.hpp ../boost_graph/graph_manager.hpp
-  ../boost_graph/graph_partitioning.hpp ../boost_graph/models.hpp)
+  ../boost_graph/graph_partitioning.hpp ../boost_graph/models.hpp
+  ../boost_graph/partitioning/utils.hpp ../boost_graph/partitioning/gggp.hpp
+  ../boost_graph/partitioning/graph_build.hpp)
 
-TARGET_LINK_LIBRARIES(pdevs-multithreading-main partitioning
+TARGET_LINK_LIBRARIES(pdevs-multithreading-main
   ${CMAKE_THREAD_LIBS_INIT}
   ${Boost_SYSTEM_LIBRARY}
   ${Boost_TIMER_LIBRARY})

+ 5 - 2
src/tests/multithreading/lifegame/CMakeLists.txt

@@ -10,9 +10,12 @@ LINK_DIRECTORIES(
   ${LIBXML_LIBRARY_DIR})
 
 ADD_EXECUTABLE(pdevs-multithreading-lifegame-main graph_manager.hpp main.cpp
-  models.hpp)
+  models.hpp
+  ../../boost_graph/partitioning/utils.hpp
+  ../../boost_graph/partitioning/gggp.hpp
+  ../../boost_graph/partitioning/graph_build.hpp)
 
-TARGET_LINK_LIBRARIES(pdevs-multithreading-lifegame-main partitioning
+TARGET_LINK_LIBRARIES(pdevs-multithreading-lifegame-main
   ${CMAKE_THREAD_LIBS_INIT}
   ${Boost_SYSTEM_LIBRARY}
   ${Boost_TIMER_LIBRARY})

+ 1 - 0
src/tests/multithreading/main.cpp

@@ -27,6 +27,7 @@
 #include <paradevs/common/RootCoordinator.hpp>
 
 #include <tests/boost_graph/models.hpp>
+#include <tests/boost_graph/graph_defs.hpp>
 #include <tests/boost_graph/graph_builder.hpp>
 #include <tests/boost_graph/graph_generator.hpp>
 #include <tests/boost_graph/graph_manager.hpp>

+ 21 - 0
src/tests/plot/CMakeLists.txt

@@ -0,0 +1,21 @@
+INCLUDE_DIRECTORIES(
+  ${CMAKE_SOURCE_DIR}/src
+  ${PARADEVS_INCLUDE_DIRS}
+  ${Boost_INCLUDE_DIRS}
+  ${GLIBMM_INCLUDE_DIRS}
+  ${LIBXML_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+  ${GLIBMM_LIBRARY_DIRS}
+  ${LIBXML_LIBRARY_DIR})
+
+ADD_EXECUTABLE(pdevs-plot-main graph_builder.hpp graph_defs.hpp
+  graph_manager.hpp main.cpp models.hpp
+  ../boost_graph/partitioning/utils.hpp
+  ../boost_graph/partitioning/defs.hpp
+  ../boost_graph/partitioning/gggp.hpp)
+
+TARGET_LINK_LIBRARIES(pdevs-plot-main shp geos
+  ${CMAKE_THREAD_LIBS_INIT}
+  ${Boost_SYSTEM_LIBRARY}
+  ${Boost_TIMER_LIBRARY})

+ 218 - 0
src/tests/plot/graph_builder.hpp

@@ -0,0 +1,218 @@
+/**
+ * @file tests/plot/graph_builder.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013-2015 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_PLOT_GRAPH_BUILDER_HPP
+#define TESTS_PLOT_GRAPH_BUILDER_HPP 1
+
+#include <tests/boost_graph/partitioning/gggp.hpp>
+
+#include <shapefil.h>
+#include <geos/geom/CoordinateArraySequenceFactory.h>
+#include <geos/geom/CoordinateSequenceFactory.h>
+#include <geos/geom/CoordinateSequence.h>
+#include <geos/geom/Coordinate.h>
+#include <geos/geom/GeometryFactory.h>
+#include <geos/geom/LinearRing.h>
+#include <geos/geom/Polygon.h>
+#include <geos/geom/PrecisionModel.h>
+#include <geos/simplify/DouglasPeuckerSimplifier.h>
+#include <geos/algorithm/CentroidArea.h>
+
+#include <map>
+
+using namespace geos;
+using namespace geos::geom;
+using namespace geos::simplify;
+using namespace paradevs::tests::boost_graph;
+
+namespace paradevs { namespace tests { namespace plot {
+
+class GraphBuilder
+{
+public:
+    GraphBuilder(const std::string& file_name, int cluster_number) :
+        _cluster_number(cluster_number), _file_name(file_name)
+    { }
+
+    void build(OrientedGraphs& graphs,
+               InputEdgeList& input_edges,
+               OutputEdgeList& output_edges,
+               Connections& parent_connections)
+    {
+        std::vector < std::string > parameters = {
+             "HEM", "rande", "diff", "ratio"
+        };
+
+        bool contraction_coef_flag = false;
+        uint cluster_number = _cluster_number;
+        OrientedGraph go;
+        Edges edge_partie;
+        Connections connections;
+
+        generate(go);
+        uint contraction_coef = 200;//num_vertices(go);
+        output_edges = OutputEdgeList(cluster_number);
+        if (contraction_coef_flag) {
+            uint coars = num_vertices(go) / contraction_coef;
+            std::vector < uint > numeric_parameters = { coars,
+                                                        cluster_number,
+                                                        10 };
+
+            graphs = Multiniveau(&go, numeric_parameters,
+                                 parameters, edge_partie,
+                                 output_edges, input_edges,
+                                 parent_connections,
+                                 false, 2);
+        } else {
+            std::vector < uint > numeric_parameters = { contraction_coef,
+                                                        cluster_number,
+                                                        10 };
+
+            graphs = Multiniveau(&go, numeric_parameters,
+                                 parameters, edge_partie ,
+                                 output_edges, input_edges,
+                                 parent_connections, false, 2);
+        }
+    }
+
+private:
+    void generate(OrientedGraph& g)
+    {
+        SHPHandle hSHP;
+
+        hSHP = SHPOpen(_file_name.c_str(), "rb" );
+
+        int nShapeType, nEntities;
+        double adfMinBound[4], adfMaxBound[4];
+
+        SHPGetInfo(hSHP, &nEntities, &nShapeType, adfMinBound, adfMaxBound);
+
+        PrecisionModel precisionModel(100., 0, 0);
+        GeometryFactory geomFactory(&precisionModel);
+        const CoordinateSequenceFactory* seqFactory =
+            CoordinateArraySequenceFactory::instance();
+        std::vector < Geometry* > holes;
+        std::map < int, Polygon* > polygons;
+        std::vector < OrientedGraph::vertex_descriptor > vertices;
+
+        // read shapefile file and build polygons
+        for (int i = 0; i < nEntities; i++) {
+            SHPObject	*psShape;
+
+            psShape = SHPReadObject(hSHP, i);
+
+            int n = psShape->nVertices;
+
+            if (psShape->padfX[0] != psShape->padfX[psShape->nVertices - 1] or
+                psShape->padfY[0] != psShape->padfY[psShape->nVertices - 1])
+                ++n;
+
+            CoordinateSequence* seq = seqFactory->create(n, 2);
+            Coordinate first;
+
+            for (int j = 0; j < n; j++) {
+                Coordinate pt(psShape->padfX[j],
+                              psShape->padfY[j]);
+
+                if (j == 0) first = pt;
+                seq->setAt(pt, j);
+            }
+            if (first != seq->back()) {
+                seq->setAt(first, n-1);
+            }
+
+            LinearRing* ring(geomFactory.createLinearRing(seq));
+            Polygon* polygon = geomFactory.createPolygon(*ring, holes);
+
+            std::auto_ptr < Geometry > object =
+                DouglasPeuckerSimplifier::simplify(polygon, 1);
+
+            polygons[i] = dynamic_cast < Polygon* >(object->clone());
+
+            geos::algorithm::CentroidArea centroid;
+
+            centroid.add(object.get());
+
+            vertices.push_back(boost::add_vertex(g));
+            g[vertices.back()] = VertexProperties(i, 1.,
+                                                  centroid.getCentroid()->x,
+                                                  centroid.getCentroid()->y);
+
+            delete ring;
+            SHPDestroyObject(psShape);
+        }
+
+        // compute neighbour
+        int buffer = 10;
+        std::map < int, Polygon* >::const_iterator it = polygons.begin();
+
+        while (it != polygons.end()) {
+            Geometry* bufferedPolygon = it->second->buffer(buffer);
+            std::map < int, Polygon* >::const_iterator it2 = polygons.begin();
+
+            while (it2 != polygons.end()) {
+                if (bufferedPolygon->intersects(it2->second)) {
+                    boost::add_edge(vertices[it->first],
+                                    vertices[it2->first], 1., g);
+                }
+                ++it2;
+            }
+            delete bufferedPolygon;
+            ++it;
+        }
+
+        it = polygons.begin();
+        while (it != polygons.end()) {
+            delete it->second;
+            ++it;
+        }
+
+        SHPClose(hSHP);
+
+        // OrientedGraph::vertex_iterator it_og, end_og;
+
+        // boost::tie(it_og, end_og) = boost::vertices(g);
+        // for (; it_og != end_og; ++it_og) {
+        //     OrientedGraph::adjacency_iterator neighbour_it, neighbour_end;
+
+        //     std::cout << g[*it_og]._index << " -> { ";
+        //     tie(neighbour_it, neighbour_end) =
+        //         boost::adjacent_vertices(*it_og, g);
+        //     for (; neighbour_it != neighbour_end; ++neighbour_it) {
+        //         std::cout << g[*neighbour_it]._index << " ";
+        //     }
+        //     std::cout << "}" << std::endl;
+        // }
+
+    }
+
+    int _cluster_number;
+    std::string _file_name;
+};
+
+} } } // namespace paradevs tests plot
+
+#endif

+ 95 - 0
src/tests/plot/graph_defs.hpp

@@ -0,0 +1,95 @@
+/**
+ * @file tests/boost_graph/graph_defs.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013-2015 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __TESTS_PLOT_GRAPH_DEFS_HPP
+#define __TESTS_PLOT_GRAPH_DEFS_HPP 1
+
+#include <boost/graph/adjacency_list.hpp>
+
+namespace paradevs { namespace tests { namespace boost_graph {
+
+struct VertexProperties
+{
+    int    _index;
+    double _weight;
+    double _x;
+    double _y;
+
+    VertexProperties() : _index(0), _weight(0), _x(0.), _y(0)
+    { }
+
+    VertexProperties(int index, double weight, double x, double y) :
+        _index(index), _weight(weight), _x(x), _y(y)
+    { }
+
+    VertexProperties(const VertexProperties& vp) :
+        _index(vp._index), _weight(vp._weight), _x(vp._x), _y(vp._y)
+    { }
+};
+
+struct EdgeProperties
+{
+    double _weight;
+
+    EdgeProperties() : _weight(0)
+    { }
+
+    EdgeProperties(double weight) : _weight(weight)
+    { }
+};
+
+typedef boost::adjacency_list < boost::vecS, boost::vecS,
+                                boost::bidirectionalS,
+                                VertexProperties,
+                                EdgeProperties > OrientedGraph;
+typedef std::vector < OrientedGraph > OrientedGraphs;
+
+typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS,
+                                VertexProperties,
+                                EdgeProperties> UnorientedGraph;
+
+typedef std::vector < UnorientedGraph* > Base_Graph;
+
+typedef boost::graph_traits < UnorientedGraph >::vertex_descriptor vertex_t;
+typedef boost::graph_traits < UnorientedGraph >::edge_descriptor edge_t;
+
+typedef OrientedGraph::vertex_descriptor vertex_to;
+typedef OrientedGraph::edge_descriptor edge_to;
+
+typedef std::pair < int, int > Edge;
+typedef std::vector < Edge > Edges;
+typedef Edges OutputEdges;
+typedef Edges InputEdges;
+typedef std::vector < OutputEdges > OutputEdgeList;
+typedef std::vector < InputEdges > InputEdgeList;
+
+typedef std::pair < int, int > Port;
+typedef std::pair < Port, Port > Connection;
+typedef std::vector < Connection > Connections;
+
+} } } // namespace paradevs tests boost_graph
+
+#endif

+ 473 - 0
src/tests/plot/graph_manager.hpp

@@ -0,0 +1,473 @@
+/**
+ * @file tests/plot/graph_manager.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013-2015 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_PLOT_GRAPH_MANAGER_HPP
+#define TESTS_PLOT_GRAPH_MANAGER_HPP 1
+
+#include <tests/plot/graph_builder.hpp>
+#include <tests/plot/models.hpp>
+
+#include <paradevs/kernel/pdevs/multithreading/Coordinator.hpp>
+#include <paradevs/kernel/pdevs/GraphManager.hpp>
+#include <paradevs/kernel/pdevs/Simulator.hpp>
+
+using namespace paradevs::tests::boost_graph;
+
+namespace paradevs { namespace tests { namespace plot {
+
+struct GraphParameters
+{
+    OrientedGraph _graph;
+    InputEdges    _input_edges;
+    OutputEdges   _output_edges;
+
+    GraphParameters(const OrientedGraph& graph,
+                    const InputEdges& input_edges,
+                    const OutputEdges& output_edges) :
+        _graph(graph), _input_edges(input_edges), _output_edges(output_edges)
+    { }
+};
+
+template < class Parameters >
+class FlatGraphManager :
+                public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                                       Parameters >
+{
+public:
+    FlatGraphManager(common::Coordinator < common::DoubleTime >* coordinator,
+                     const Parameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime, Parameters >(
+            coordinator, parameters)
+    { }
+
+    virtual ~FlatGraphManager()
+    {
+        for (typename Simulators::const_iterator it =
+                 _simulators.begin(); it != _simulators.end();
+             ++it) {
+            delete it->second;
+        }
+    }
+
+    void build_flat_graph(const OrientedGraph& g, const InputEdges& inputs)
+    {
+        OrientedGraph::vertex_iterator vertexIt, vertexEnd;
+        std::map < int, int > neighbour_numbers;
+
+        boost::tie(vertexIt, vertexEnd) = boost::vertices(g);
+        for (; vertexIt != vertexEnd; ++vertexIt)
+        {
+            OrientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+            neighbour_numbers[g[*vertexIt]._index] = 0;
+            boost::tie(neighbourIt, neighbourEnd) =
+                boost::adjacent_vertices(*vertexIt, g);
+            for (; neighbourIt != neighbourEnd; ++neighbourIt) {
+                ++neighbour_numbers[g[*vertexIt]._index];
+            }
+        }
+
+        for (Edges::const_iterator it = inputs.begin(); it != inputs.end();
+             ++it) {
+            ++neighbour_numbers[it->second];
+        }
+
+        boost::tie(vertexIt, vertexEnd) = boost::vertices(g);
+        for (; vertexIt != vertexEnd; ++vertexIt) {
+            std::ostringstream ss;
+
+            ss << "a" << g[*vertexIt]._index;
+            _simulators[g[*vertexIt]._index] =
+                new Simulator(ss.str(),
+                              PlotParameters(g[*vertexIt]._x, g[*vertexIt]._y,
+                                  neighbour_numbers[g[*vertexIt]._index]));
+            _simulators[g[*vertexIt]._index]->add_out_port("out");
+            _simulators[g[*vertexIt]._index]->add_in_port("in");
+            FlatGraphManager < Parameters >::add_child(
+                _simulators[g[*vertexIt]._index]);
+        }
+
+        boost::tie(vertexIt, vertexEnd) = boost::vertices(g);
+        for (; vertexIt != vertexEnd; ++vertexIt)
+        {
+            OrientedGraph::adjacency_iterator neighbourIt, neighbourEnd;
+
+            boost::tie(neighbourIt, neighbourEnd) =
+                boost::adjacent_vertices(*vertexIt, g);
+            for (; neighbourIt != neighbourEnd; ++neighbourIt) {
+                paradevs::common::Model < common::DoubleTime >* a = 0;
+                paradevs::common::Model < common::DoubleTime >* b = 0;
+
+                a = _simulators[g[*vertexIt]._index];
+                b = _simulators[g[*neighbourIt]._index];
+                FlatGraphManager < Parameters >::add_link(a, "out",
+                                                          b, "in");
+            }
+        }
+    }
+
+protected:
+    typedef pdevs::Simulator < common::DoubleTime,
+                               Plot,
+                               PlotParameters > Simulator;
+    typedef std::map < int, Simulator* > Simulators;
+
+    Simulators _simulators;
+};
+
+class BuiltFlatGraphManager :
+        public FlatGraphManager < GraphParameters >
+{
+public:
+    BuiltFlatGraphManager(
+        common::Coordinator < common::DoubleTime >* coordinator,
+        const GraphParameters& parameters) :
+        FlatGraphManager < GraphParameters >(
+            coordinator, parameters)
+    {
+        BuiltFlatGraphManager::build_flat_graph(
+            parameters._graph, parameters._input_edges);
+
+        // input
+        for (Edges::const_iterator it = parameters._input_edges.begin();
+             it != parameters._input_edges.end(); ++it) {
+            std::ostringstream ss_in;
+
+            ss_in << "in_" << it->first;
+            if (not coordinator->exist_in_port(ss_in.str())) {
+                coordinator->add_in_port(ss_in.str());
+            }
+            BuiltFlatGraphManager::add_link(
+                coordinator, ss_in.str(),
+                BuiltFlatGraphManager::_simulators[it->second], "in");
+        }
+
+        // output
+        for (Edges::const_iterator it = parameters._output_edges.begin();
+             it != parameters._output_edges.end(); ++it) {
+            std::ostringstream ss_out;
+
+            ss_out << "out_" << it->first;
+            if (not coordinator->exist_out_port(ss_out.str())) {
+                coordinator->add_out_port(ss_out.str());
+            }
+            if (not BuiltFlatGraphManager::exist_link(
+                    BuiltFlatGraphManager::_simulators[it->first],
+                    "out", coordinator, ss_out.str())) {
+                BuiltFlatGraphManager::add_link(
+                    BuiltFlatGraphManager::_simulators[it->first],
+                    "out", coordinator, ss_out.str());
+            }
+        }
+    }
+
+    virtual ~BuiltFlatGraphManager()
+    { }
+};
+
+class ParallelBuiltFlatGraphManager :
+        public FlatGraphManager < GraphParameters >
+{
+public:
+    ParallelBuiltFlatGraphManager(
+        common::Coordinator < common::DoubleTime >* coordinator,
+        const GraphParameters& parameters) :
+        FlatGraphManager < GraphParameters >(
+            coordinator, parameters)
+    {
+        ParallelBuiltFlatGraphManager::build_flat_graph(
+            parameters._graph, parameters._input_edges);
+
+        // input
+        for (Edges::const_iterator it = parameters._input_edges.begin();
+             it != parameters._input_edges.end(); ++it) {
+            std::ostringstream ss_in;
+
+            ss_in << "in_" << it->first;
+            if (not coordinator->exist_in_port(ss_in.str())) {
+                coordinator->add_in_port(ss_in.str());
+            }
+            ParallelBuiltFlatGraphManager::add_link(
+                coordinator, ss_in.str(),
+                ParallelBuiltFlatGraphManager::_simulators[it->second],
+                "in");
+        }
+
+        // output
+        for (Edges::const_iterator it = parameters._output_edges.begin();
+             it != parameters._output_edges.end(); ++it) {
+            std::ostringstream ss_out;
+
+            ss_out << "out_" << it->first;
+            if (not coordinator->exist_out_port(ss_out.str())) {
+                coordinator->add_out_port(ss_out.str());
+            }
+            if (not ParallelBuiltFlatGraphManager::exist_link(
+                    ParallelBuiltFlatGraphManager::_simulators[it->first],
+                    "out", coordinator, ss_out.str())) {
+                ParallelBuiltFlatGraphManager::add_link(
+                    ParallelBuiltFlatGraphManager::_simulators[it->first],
+                    "out", coordinator, ss_out.str());
+            }
+        }
+    }
+
+    void init()
+    { }
+
+    void start(common::DoubleTime::type /* t */)
+    { }
+
+    void transition(
+        const common::Models < common::DoubleTime >& /* receivers */,
+        common::DoubleTime::type /* t */)
+    { }
+
+    virtual ~ParallelBuiltFlatGraphManager()
+    { }
+};
+
+struct GraphManagerParameters
+{
+    GraphManagerParameters(const std::string& file_name,
+                           int cluster_number) :
+        cluster_number(cluster_number), file_name(file_name)
+    { }
+
+    int cluster_number;
+    std::string file_name;
+};
+
+class HierarchicalGraphManager :
+                public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                                       GraphManagerParameters >
+{
+public:
+    HierarchicalGraphManager(
+        common::Coordinator < common::DoubleTime >* coordinator,
+        const GraphManagerParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        GraphManagerParameters >(
+                                            coordinator, parameters)
+    {
+        GraphBuilder graph_builder(parameters.file_name,
+                                   parameters.cluster_number);
+        OrientedGraphs graphs;
+        InputEdgeList  input_edges;
+        OutputEdgeList output_edges;
+        Connections    parent_connections;
+
+        graph_builder.build(graphs, input_edges, output_edges,
+                            parent_connections);
+
+        // build coordinators (graphs)
+        for (unsigned int i = 0; i < graphs.size(); ++i) {
+            Coordinator* coordinator = 0;
+            std::ostringstream ss;
+
+            ss << "S" << i;
+            coordinator =
+                new Coordinator(ss.str(), paradevs::common::NoParameters(),
+                                GraphParameters(graphs[i],
+                                                input_edges[i],
+                                                output_edges[i]));
+            _coordinators.push_back(coordinator);
+            add_child(coordinator);
+        }
+
+        // builds internal connections (edges)
+        for (Connections::const_iterator it = parent_connections.begin();
+             it != parent_connections.end(); ++it) {
+            const Connection& connection = *it;
+            std::ostringstream ss_out;
+            std::ostringstream ss_in;
+
+            ss_out << "out_" << connection.first.second;
+            ss_in << "in_" << connection.first.second;
+
+            if (not exist_link(
+                    _coordinators[connection.first.first - 1],
+                    ss_out.str(),
+                    _coordinators[connection.second.first - 1],
+                    ss_in.str())) {
+
+                add_link(
+                    _coordinators[connection.first.first - 1],
+                    ss_out.str(),
+                    _coordinators[connection.second.first - 1],
+                    ss_in.str());
+            }
+        }
+    }
+
+    virtual ~HierarchicalGraphManager()
+    {
+        for (typename Coordinators::const_iterator it = _coordinators.begin();
+             it != _coordinators.end(); ++it) {
+            delete *it;
+        }
+    }
+
+private:
+    typedef paradevs::pdevs::Coordinator <
+        common::DoubleTime,
+        BuiltFlatGraphManager,
+        common::NoParameters,
+        GraphParameters
+    > Coordinator;
+    typedef std::vector < Coordinator* > Coordinators;
+
+    Coordinators _coordinators;
+};
+
+class ParallelHierarchicalGraphManager :
+                public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                                       GraphManagerParameters >
+{
+public:
+    ParallelHierarchicalGraphManager(
+        common::Coordinator < common::DoubleTime >* coordinator,
+        const GraphManagerParameters& parameters) :
+        paradevs::pdevs::GraphManager < common::DoubleTime,
+                                        GraphManagerParameters >(
+                                            coordinator, parameters)
+    {
+        GraphBuilder   graph_builder(parameters.file_name,
+                                     parameters.cluster_number);
+        OrientedGraphs graphs;
+        InputEdgeList  input_edges;
+        OutputEdgeList output_edges;
+        Connections    parent_connections;
+
+        graph_builder.build(graphs, input_edges, output_edges,
+                            parent_connections);
+
+        // build coordinators (graphs)
+        for (unsigned int i = 0; i < graphs.size(); ++i) {
+            ParallelCoordinator* coordinator = 0;
+            std::ostringstream ss;
+
+            ss << "S" << i;
+            coordinator =
+                new ParallelCoordinator(ss.str(),
+                                        paradevs::common::NoParameters(),
+                                        GraphParameters(graphs[i],
+                                                        input_edges[i],
+                                                        output_edges[i]));
+            _coordinators.push_back(coordinator);
+            add_child(coordinator);
+        }
+
+        // builds internal connections (edges)
+        for (Connections::const_iterator it = parent_connections.begin();
+             it != parent_connections.end(); ++it) {
+            const Connection& connection = *it;
+            std::ostringstream ss_out;
+            std::ostringstream ss_in;
+
+            ss_out << "out_" << connection.first.second;
+            ss_in << "in_" << connection.first.second;
+
+            if (not exist_link(
+                    _coordinators[connection.first.first - 1],
+                    ss_out.str(),
+                    _coordinators[connection.second.first - 1],
+                    ss_in.str())) {
+                add_link(
+                    _coordinators[connection.first.first - 1],
+                    ss_out.str(),
+                    _coordinators[connection.second.first - 1],
+                    ss_in.str());
+            }
+        }
+    }
+
+    virtual ~ParallelHierarchicalGraphManager()
+    {
+        for (typename Coordinators::const_iterator it = _coordinators.begin();
+             it != _coordinators.end(); ++it) {
+            delete *it;
+        }
+    }
+
+    void init()
+    {
+        for (typename Coordinators::const_iterator it = _coordinators.begin();
+             it != _coordinators.end(); ++it) {
+            (*it)->set_sender(
+                dynamic_cast < paradevs::pdevs::multithreading::Coordinator <
+                    common::DoubleTime,
+                    ParallelHierarchicalGraphManager,
+                    paradevs::common::NoParameters,
+                    GraphManagerParameters >*
+                >(get_coordinator())->get_sender());
+        }
+    }
+
+    void start(common::DoubleTime::type t)
+    {
+        for (typename Coordinators::const_iterator it = _coordinators.begin();
+             it != _coordinators.end(); ++it) {
+            (*it)->get_sender().send(
+                paradevs::pdevs::multithreading::start_message <
+                    paradevs::common::DoubleTime >(t));
+        }
+    }
+
+    void transition(const common::Models < common::DoubleTime >& receivers,
+                    paradevs::common::DoubleTime::type t)
+    {
+        common::Models < common::DoubleTime >::const_iterator it =
+            receivers.begin();
+
+        while (it != receivers.end()) {
+            if (not (*it)->is_atomic()) {
+                typename Coordinators::const_iterator itc =
+                    std::find(_coordinators.begin(), _coordinators.end(), *it);
+
+                (*itc)->get_sender().send(
+                    paradevs::pdevs::multithreading::transition_message <
+                        paradevs::common::DoubleTime >(t));
+            }
+            ++it;
+        }
+    }
+
+private:
+    typedef paradevs::pdevs::multithreading::Coordinator <
+      common::DoubleTime,
+      ParallelBuiltFlatGraphManager,
+      common::NoParameters,
+      GraphParameters
+    > ParallelCoordinator;
+    typedef std::vector < ParallelCoordinator* > Coordinators;
+
+    Coordinators _coordinators;
+};
+
+} } } // namespace paradevs tests plot
+
+#endif

+ 102 - 0
src/tests/plot/main.cpp

@@ -0,0 +1,102 @@
+/**
+ * @file tests/plot/main.cpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013-2015 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <paradevs/common/RootCoordinator.hpp>
+
+#include <tests/plot/graph_defs.hpp>
+#include <tests/plot/graph_builder.hpp>
+#include <tests/plot/graph_manager.hpp>
+
+#include <chrono>
+
+using namespace paradevs::common;
+using namespace std::chrono;
+using namespace paradevs::tests::plot;
+
+double plot_monothreading()
+{
+    paradevs::common::RootCoordinator <
+        DoubleTime, paradevs::pdevs::Coordinator <
+            DoubleTime,
+            HierarchicalGraphManager,
+            paradevs::common::NoParameters,
+            GraphManagerParameters >
+        > rc(0, 10, "root", paradevs::common::NoParameters(),
+             GraphManagerParameters("/home/eric/tmp/parcelle/oye_plage.shp",
+                                    4));
+
+    steady_clock::time_point t1 = steady_clock::now();
+
+    rc.run();
+
+    steady_clock::time_point t2 = steady_clock::now();
+
+    duration < double > time_span = duration_cast <
+        duration < double > >(t2 - t1);
+
+    return time_span.count();
+}
+
+double plot_multithreading(int cluster_number)
+{
+    paradevs::common::RootCoordinator <
+        DoubleTime, paradevs::pdevs::multithreading::Coordinator <
+            DoubleTime,
+            ParallelHierarchicalGraphManager,
+            paradevs::common::NoParameters,
+            GraphManagerParameters >
+        > rc(0, 10, "root", paradevs::common::NoParameters(),
+             GraphManagerParameters("/home/eric/tmp/parcelle/oye_plage.shp",
+                                    cluster_number));
+
+    steady_clock::time_point t1 = steady_clock::now();
+
+    rc.run();
+
+    steady_clock::time_point t2 = steady_clock::now();
+
+    duration < double > time_span = duration_cast <
+        duration < double > >(t2 - t1);
+
+    return time_span.count();
+}
+
+void plot(int n)
+{
+    if (n == 1) {
+        std::cout << plot_monothreading() << std::endl;
+    } else {
+        std::cout << plot_multithreading(n) << std::endl;
+    }
+}
+
+int main(int argc, char** argv)
+{
+    if (argc > 1) {
+        plot(atoi(argv[1]));
+    }
+    return 0;
+}

+ 127 - 0
src/tests/plot/models.hpp

@@ -0,0 +1,127 @@
+/**
+ * @file tests/plot/models.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013-2015 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TESTS_PLOT_MODELS_HPP
+#define TESTS_PLOT_MODELS_HPP 1
+
+#include <paradevs/common/time/DoubleTime.hpp>
+
+#include <paradevs/kernel/pdevs/Dynamics.hpp>
+
+namespace paradevs { namespace tests { namespace plot {
+
+struct PlotParameters
+{
+    PlotParameters(double x, double y, int n) : x(x), y(y), neighbour_number(n)
+    { }
+
+    double x;
+    double y;
+    int neighbour_number;
+};
+
+struct PlotData
+{
+    PlotData() : x(-1), y(-1), quantity(0)
+    { }
+
+    PlotData(double x, double y, double quantity) : x(x), y(y),
+                                                    quantity(quantity)
+    { }
+
+    double x;
+    double y;
+    double quantity;
+};
+
+class Plot : public paradevs::pdevs::Dynamics < common::DoubleTime,
+                                                PlotParameters >
+{
+public:
+    Plot(const std::string& name, const PlotParameters& parameters) :
+        paradevs::pdevs::Dynamics < common::DoubleTime, PlotParameters >(
+            name, parameters),
+        _neighbour_number(parameters.neighbour_number)
+    {
+        _data.x = parameters.x;
+        _data.y = parameters.y;
+    }
+
+    virtual ~Plot()
+    { }
+
+    void dint(typename common::DoubleTime::type /* t */)
+    {
+    }
+
+    void dext(typename common::DoubleTime::type /* t */,
+              typename common::DoubleTime::type /* e */,
+              const common::Bag < common::DoubleTime >& /* bag */)
+    {
+    }
+
+    void dconf(typename common::DoubleTime::type /* t */,
+               typename common::DoubleTime::type /* e */,
+               const common::Bag < common::DoubleTime >& /* bag */)
+    {
+        // dext(t, e, bag);
+    }
+
+    typename common::DoubleTime::type start(
+        typename common::DoubleTime::type /* t */)
+    {
+        _data.quantity = 0;
+        return 0;
+    }
+
+    typename common::DoubleTime::type ta(
+        typename common::DoubleTime::type /* t */) const
+    { return common::DoubleTime::infinity; }
+
+    common::Bag < common::DoubleTime > lambda(
+        typename common::DoubleTime::type /* t */) const
+    {
+        common::Bag < common::DoubleTime > bag;
+
+        bag.push_back(common::ExternalEvent < common::DoubleTime >(
+                          "out", (void*)(&_data)));
+        return bag;
+    }
+
+    void observation(std::ostream& /* file */) const
+    { }
+
+private:
+    // parameters
+    unsigned int _neighbour_number;
+
+    // data
+    PlotData _data;
+};
+
+} } } // namespace paradevs tests plot
+
+#endif