Quellcode durchsuchen

Merge branch 'master' of https://github.com/devs-labs/paradevs-tests

totofeh vor 9 Jahren
Ursprung
Commit
649565857d

+ 18 - 19
src/tests/boost_graph/file_generator.cpp

@@ -28,7 +28,6 @@
 #include <fstream>
 #include <boost/timer.hpp>
 
-//#include <tests/boost_graph/partitioning/graph_build.hpp>
 #include <tests/boost_graph/graph_generator.hpp>
 #include <tests/boost_graph/graph_partitioning.hpp>
 
@@ -48,16 +47,16 @@ int main()
     Entiers weight_vertex;
     weight_vertex.push_back(1);
     const char *texte = "../../sortie_graphe/tests_grid.txt";
-    RandomGridGraphGenerator generator(side, vertex_selection, 
+    RandomGridGraphGenerator generator(side, vertex_selection,
 									weight_vertex, texte, true);*/
-									
+
 	/** Tree **/
 	/*int nbr_sommets = 20000;
-	int sources = nbr_sommets/100*1; 
+	int sources = nbr_sommets/100*1;
 	Entiers levels = {5,4,3,2};
 	//Text_generator_graph("file/data_base/linked/linked_10000.txt", &gtmp);
 	RandomGraphGenerator generator(nbr_sommets, levels, sources, 2, 3);*/
-	
+
 	/** Linked **/
 	//OrientedGraph gtmp;
 	//int nbr_sommets = 10000;
@@ -65,14 +64,14 @@ int main()
 	//RandomLinkedGraphGenerator generator(nbr_sommets, nbr_couches, 2, 3);
 	//generator.generate(gtmp);
 	//Text_generator_graph("file/data_base/linked/linked_10000.txt", &gtmp);
-	
+
 	//ArtificialGraphGenerator generator(38);
-	
+
 	ParcelGraphGenerator generator(10000, "mono");
 	std::cout << "Duration : " << t.elapsed() << " seconds" << std::endl;
-	
+
 	OrientedGraph::vertex_iterator vertexIt, vertexEnd;
-	
+
 	/*UnorientedGraph gi;
 	OrientedGraph go;
 	generator.generate(go);
@@ -108,14 +107,14 @@ int main()
 		}
 	}*/
 
-	/**Liste des méthodes possible : 
+	/**Liste des méthodes possible :
 	 * gggp
 	 * ggp
 	 * rand
 	 **/
     PartitioningGraphBuilder graph_builder(4, "gggp", 200,
                                            false, generator);
-                                           
+
     OrientedGraphs graphs;
     InputEdgeList  input_edges;
     OutputEdgeList output_edges;
@@ -123,9 +122,9 @@ int main()
 
     graph_builder.build(graphs, input_edges, output_edges,
                         parent_connections);
-                        
+
     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");
     name.push_back("../../sortie_graphe/Tests/Graphes/Multiniveau/txt/partie_1.txt");
@@ -144,7 +143,7 @@ int main()
         Edges& inputs = input_edges[i];
         Edges& outputs = output_edges[i];
         std::map < int, int > indexes;
-        
+
         //std::cout<<num_vertices(graphs[i])<<std::endl;
         //Plot_OrientedGraph(&graphs[i],name.at(i));
         std::ofstream f((boost::format("file/data_base/linked/rand/S%1%.tgf") % i).str());
@@ -157,10 +156,10 @@ int main()
         for (; vertexIt != vertexEnd; ++vertexIt) {
             indexes[g[*vertexIt]._index] = k;
             switch (g[*vertexIt]._type) {
-            case TOP_PIXEL:
+            case 0 /*TOP_PIXEL*/:
                 f << "top " << std::endl;
                 break;
-            case NORMAL_PIXEL:
+            case 1 /*NORMAL_PIXEL*/:
                 f << "normal " << std::endl;
                 break;
             };
@@ -191,7 +190,7 @@ int main()
 
         // output
         std::vector < int > outs;
-		
+
         for (Edges::const_iterator it = outputs.begin(); it != outputs.end(); ++it) {
             if (std::find(outs.begin(), outs.end(), it->first) == outs.end()) {
                 f << indexes[it->first] << " 0 0 " << it->first << std::endl;
@@ -214,9 +213,9 @@ int main()
     for (Connections::const_iterator it = parent_connections.begin();
          it != parent_connections.end(); ++it) {
        const Connection& connection = *it;
-	   std::pair<int, int> tmp_outs; 
+	   std::pair<int, int> tmp_outs;
 	   tmp_outs.first = connection.first.second;
-	   tmp_outs.second = connection.second.first;		
+	   tmp_outs.second = connection.second.first;
        //if (std::find(outs.begin(), outs.end(), connection.) == outs.end()) {
        if(std::find(Outs.begin(), Outs.end(), tmp_outs) == Outs.end()){
 	   //} else{

+ 16 - 16
src/tests/boost_graph/graph_builder.hpp

@@ -334,9 +334,9 @@ public:
                Connections& )
     {
 		/*
-		 * *** Graphe créé différent du graphe obtenu dans graph_partitioning ! Solution ? *** 
+		 * *** Graphe créé différent du graphe obtenu dans graph_partitioning ! Solution ? ***
 		 */
-		
+
         /*
         const char *texte = new const char();
         texte = "enregistrement.txt";
@@ -344,7 +344,7 @@ public:
         OrientedGraph graph;
         unsigned int edge_number = 200;
         std::vector<int> levels = {/*5,4,*/ 3, 2 };
-        
+
         unsigned int source_number = edge_number/100*1;
         unsigned int min_neigh = 2;
         unsigned int max_neigh = 3;
@@ -367,18 +367,18 @@ public:
                Connections& )
     {
 		/*
-		 * *** Graphe créé différent du graphe obtenu dans graph_partitioning ! Solution ? *** 
+		 * *** Graphe créé différent du graphe obtenu dans graph_partitioning ! Solution ? ***
 		 */
-		
+
         /*
         const char *texte = new const char();
         texte = "enregistrement.txt";
         Graph_constructor_txt(texte, &graph);*/
-        
+
         OrientedGraph graph;
         unsigned int edge_number = 5000;
         unsigned int levels = 60;
-        
+
         unsigned int min_neigh = 2;
         unsigned int max_neigh = 3;
 
@@ -398,25 +398,25 @@ public:
                OutputEdgeList& ,
                Connections& )
     {
-        
+
         OrientedGraph graph;
-        unsigned int side = 90;
+        unsigned int side = 20;
         std::vector<std::pair<int,int>> vertex_selection;
         std::pair<int,int> tmp;
         tmp.first = 0;
-		tmp.second = 3;
+        tmp.second = 3;
         vertex_selection.push_back(tmp);
         Entiers weight_vertex;
         weight_vertex.push_back(1);
         const char *edge_weight;
         edge_weight = "../../sortie_graphe/tests_grid.txt";
         bool rec = false;
-        
-		
-		build_graph_grid(&graph, side, vertex_selection,  weight_vertex, edge_weight, rec);;
+
+
+        build_graph_grid(&graph, side, vertex_selection, weight_vertex,
+                         edge_weight, rec);
         graphs.push_back(graph);
     }
-
 };
 
 //créationd de la classe ParcelFlatGraphBuilder
@@ -430,11 +430,11 @@ public:
                OutputEdgeList& ,
                Connections& )
     {
-        
+
         OrientedGraph graph;
         uint size_max = 1000;
         std::string name = "mono";
-        
+
 		build_parcellaire_graph(&graph, size_max, name);
         graphs.push_back(graph);
     }

+ 11 - 12
src/tests/boost_graph/graph_defs.hpp

@@ -31,26 +31,23 @@
 
 namespace paradevs { namespace tests { namespace boost_graph {
 
-enum DynamicsType {
-	TOP_PIXEL = 0, NORMAL_PIXEL
-};
-
 struct VertexProperties
 {
-    int          _index;
-    double       _weight;
-    DynamicsType _type;
+    int    _index;
+    double _weight;
+    int    _type;
 
-    VertexProperties() : _index(0), _weight(0), _type(NORMAL_PIXEL)
+    VertexProperties() : _index(0), _weight(0), _type(0)
     { }
-    VertexProperties(int index, double weight, DynamicsType type) :
+
+    VertexProperties(int index, double weight, int type) :
         _index(index), _weight(weight), _type(type)
     { }
 };
 
 struct EdgeProperties
 {
-    double       _weight;
+    double _weight;
 
     EdgeProperties() : _weight(0)
     { }
@@ -58,8 +55,10 @@ struct EdgeProperties
     { }
 };
 
-typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::bidirectionalS,//boost::directedS,
-                                VertexProperties, EdgeProperties> OrientedGraph;
+typedef boost::adjacency_list < boost::vecS, boost::vecS,
+                                boost::bidirectionalS,
+                                VertexProperties,
+                                EdgeProperties > OrientedGraph;
 typedef std::vector < OrientedGraph > OrientedGraphs;
 
 typedef std::pair < int, int > Edge;

+ 4 - 27
src/tests/boost_graph/graph_manager.hpp

@@ -41,29 +41,6 @@
 
 namespace paradevs { namespace tests { namespace boost_graph {
 
-// struct SchedulerHandle;
-
-// typedef typename paradevs::common::scheduler::HeapScheduler <
-//     common::DoubleTime, SchedulerHandle >::type SchedulerType;
-
-// struct SchedulerHandle
-// {
-//     SchedulerHandle()
-//     { }
-
-//     SchedulerHandle(const SchedulerType::handle_type& handle)
-//         : _handle(handle)
-//     { }
-
-//     const SchedulerHandle& handle() const
-//     { return *this; }
-
-//     void handle(const SchedulerHandle& handle)
-//     { _handle = handle._handle; }
-
-//     SchedulerType::handle_type _handle;
-// };
-
 struct GraphParameters
 {
     OrientedGraph _graph;
@@ -113,7 +90,7 @@ public:
 
             ss << "a" << g[*vertexIt]._index;
             switch (g[*vertexIt]._type) {
-            case TOP_PIXEL:
+            case 0 /*TOP_PIXEL*/:
                 _top_simulators[g[*vertexIt]._index] =
                     new pdevs::Simulator <
                         common::DoubleTime, TopPixel,
@@ -122,7 +99,7 @@ public:
                 FlatGraphManager < Parameters >::add_child(
                     _top_simulators[g[*vertexIt]._index]);
                 break;
-            case NORMAL_PIXEL:
+            case 1 /*NORMAL_PIXEL*/:
                 unsigned int n = 0;
                 OrientedGraph::vertex_iterator vertexIt2, vertexEnd2;
 
@@ -169,12 +146,12 @@ public:
                 paradevs::common::Model < common::DoubleTime >* a = 0;
                 paradevs::common::Model < common::DoubleTime >* b = 0;
 
-                if (g[*vertexIt]._type == TOP_PIXEL) {
+                if (g[*vertexIt]._type == 0 /*TOP_PIXEL*/) {
                     a = _top_simulators[g[*vertexIt]._index];
                 } else {
                     a = _normal_simulators[g[*vertexIt]._index];
                 }
-                if (g[*neighbourIt]._type == TOP_PIXEL) {
+                if (g[*neighbourIt]._type == 0 /*TOP_PIXEL*/) {
                     b = _top_simulators[g[*neighbourIt]._index];
                 } else {
                     b = _normal_simulators[g[*neighbourIt]._index];

+ 56 - 54
src/tests/boost_graph/partitioning/gggp.hpp

@@ -33,72 +33,74 @@
 namespace paradevs { namespace tests { namespace boost_graph {
 
 void ggp(UnorientedGraph *g, Entiers *sommetsSource,
-							Entiers *sommetsDestination, 
-							EntiersEntiers &Partition, 
-							int rand , int &index_partition,
-							int distance);
+         Entiers *sommetsDestination,
+         EntiersEntiers &Partition,
+         int rand , int &index_partition,
+         int distance);
 
 void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource,
-							Entiers *sommetsDestination, 
-							EntiersEntiers &Partition, int rand, 
-							int &index_partition,
-							const std::string &name, int distance);
+               Entiers *sommetsDestination,
+               EntiersEntiers &Partition, int rand,
+               int &index_partition,
+               const std::string &name, int distance);
 
 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 = -1);
+             const std::string &nom_cut, int nbr_tirage,
+             const std::string &nom_strat, bool rec,
+             int distance = -1);
 
 void bissectionRec(UnorientedGraph *g, EntiersEntiers &Partition,
-							int nbr_parties, const std::string &nom_cut, 
-							int nbr_tirage, const std::string &nom_strat,
-							int distance = -1);
+                   int nbr_parties, const std::string &nom_cut,
+                   int nbr_tirage, const std::string &nom_strat,
+                   int distance = -1);
 
-void Pseudo_random_partitioning(UnorientedGraph *g, 
-							EntiersEntiers &Partition,
-                            uint nbr_parties);
+void Pseudo_random_partitioning(UnorientedGraph *g,
+                                EntiersEntiers &Partition,
+                                uint nbr_parties);
 
 EntiersEntiers Random_equal_weight_partitioning(UnorientedGraph *g,
-                            uint parts_number);
-                            
+                                                uint parts_number);
+
 EntiersEntiers Random_partitioning(UnorientedGraph *g,
-                            uint parts_number);
+                                   uint parts_number);
 
 OrientedGraphs Multiniveau(OrientedGraph *go,
-							const std::vector<uint> &numeric_parameters,
-							const std::vector<std::string> &parameters, 
-							Edges &edge_partie,
-							OutputEdgeList &outputedgeslist,
-							InputEdgeList &inputedgelist,
-							Connections &connections,
-							bool rec, int distance = -1);
-
-void Optimisation_method_neighbour(UnorientedGraph *g, 
-						    EntiersEntiers &Partition,
-							int index_partition, int nbr_tirage,
-						    const std::string &name_cut, 
-				   		    const std::string &name_strat);
-								   
-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);
-							
-void Optimisation_method_neighbour_degree(UnorientedGraph *g, 
-							EntiersEntiers &Partition, 
-							int index_partition, 
-							const std::string &name_cut, 
-							const std::string &name_strat);
-							
-void Optimisation_method_neighbour_minweight(UnorientedGraph *g, 
-							EntiersEntiers &Partition, 
-							int index_partition,
-							const std::string &name_cut, 
-							const std::string &name_strat);
-							
-void tirage_distance(UnorientedGraph *g, int tirage, 
-							std::list<int> &vertex_list, int distance);
+                           const std::vector<uint> &numeric_parameters,
+                           const std::vector<std::string> &parameters,
+                           Edges &edge_partie,
+                           OutputEdgeList &outputedgeslist,
+                           InputEdgeList &inputedgelist,
+                           Connections &connections,
+                           bool rec, int distance = -1);
+
+void Optimisation_method_neighbour(UnorientedGraph *g,
+                                   EntiersEntiers &Partition,
+                                   int index_partition, int nbr_tirage,
+                                   const std::string &name_cut,
+                                   const std::string &name_strat);
+
+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);
+
+void Optimisation_method_neighbour_degree(UnorientedGraph *g,
+                                          EntiersEntiers &Partition,
+                                          int index_partition,
+                                          const std::string &name_cut,
+                                          const std::string &name_strat);
+
+void Optimisation_method_neighbour_minweight(UnorientedGraph *g,
+                                             EntiersEntiers &Partition,
+                                             int index_partition,
+                                             const std::string &name_cut,
+                                             const std::string &name_strat);
+
+void tirage_distance(UnorientedGraph *g, int tirage,
+                     std::list<int> &vertex_list, int distance);
 
 } } } // namespace paradevs tests boost_graph
 

+ 11 - 7
src/tests/boost_graph/partitioning/graph_build.hpp

@@ -33,22 +33,26 @@
 
 namespace paradevs { namespace tests { namespace boost_graph {
 
+enum DynamicsType {
+	TOP_PIXEL = 0, NORMAL_PIXEL
+};
+
 void build_graph(OrientedGraph& og, unsigned int edge_number);
 
-void build_generator_graph(OrientedGraph *go, int nbr_vertex, 
-				int nbr_source, int nbr_v_min, int nbr_v_max, 
+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);
 
 void build_generator_graph_linked(OrientedGraph *go, int nbr_vertex,
 				int nbr_couche, int nbr_v_min, int nbr_v_max);
-				
+
 void build_graph_cyclique(OrientedGraph& og);
 
-void build_graph_grid(OrientedGraph *go, int side, 
+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, 
+				const Entiers &weight_vertex, const char *edge_weight,
 				bool rec);
-				
+
 void build_example_linked9(OrientedGraph& og);
 
 void build_example_ligne(OrientedGraph& og);
@@ -56,7 +60,7 @@ void build_example_ligne(OrientedGraph& og);
 void build_example_grid(OrientedGraph& og);
 
 void build_parcellaire_graph(OrientedGraph *go, uint size_max, std::string name);
-				
+
 //void build_corsen_graph(OrientedGraph& graph);
 
 } } } // namespace paradevs tests boost_graph;

+ 190 - 188
src/tests/boost_graph/partitioning/utils.cpp

@@ -499,7 +499,7 @@ double Modif_Cut_one_cluster(Entiers &cluster, UnorientedGraph &g, double &vol,
 	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);
@@ -695,13 +695,13 @@ bool contraction_HEM(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &
 	 * 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++){
@@ -861,7 +861,7 @@ bool contraction_HEM_tests(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEnt
 	/*
 	 * Pour chaque sommet non verrouiller faire ....
 	 */
-	 
+
 	//std::cout<<"Nouvelle contraction !!!"<<std::endl;
 	//std::cout<<std::endl;
 	for(uint i=0; i<nbr_vertex; i++){
@@ -922,7 +922,7 @@ bool contraction_HEM_tests(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEnt
 					//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());
 				/*
@@ -930,7 +930,7 @@ bool contraction_HEM_tests(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEnt
 				 * 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){
@@ -1031,12 +1031,12 @@ bool contraction_HEM_max_degree_selection(UnorientedGraph *g, Base_Graph &baseg,
 	 */
 	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));
@@ -1060,7 +1060,7 @@ bool contraction_HEM_max_degree_selection(UnorientedGraph *g, Base_Graph &baseg,
 				}
 
 				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);
@@ -1083,10 +1083,10 @@ bool contraction_HEM_max_degree_selection(UnorientedGraph *g, Base_Graph &baseg,
 				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
@@ -1098,14 +1098,14 @@ bool contraction_HEM_max_degree_selection(UnorientedGraph *g, Base_Graph &baseg,
 				}
 
 				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)
@@ -1165,7 +1165,7 @@ bool contraction_HEM_max_degree_selection(UnorientedGraph *g, Base_Graph &baseg,
 	 * 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);
 	}
@@ -1173,12 +1173,12 @@ bool contraction_HEM_max_degree_selection(UnorientedGraph *g, Base_Graph &baseg,
 	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){
@@ -1196,12 +1196,12 @@ bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEn
 	 * 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;
@@ -1212,10 +1212,10 @@ bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEn
 				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){
@@ -1230,13 +1230,13 @@ bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEn
 				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;
@@ -1252,10 +1252,10 @@ bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEn
 			}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);
@@ -1278,10 +1278,10 @@ bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEn
 			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
@@ -1293,14 +1293,14 @@ bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEn
 			}
 
 			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)
@@ -1374,7 +1374,7 @@ bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEn
 	 * 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);
 	}
@@ -1382,7 +1382,7 @@ bool contraction_HEM_degree(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEn
 	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
@@ -1405,13 +1405,13 @@ bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg, List
 	 */
 	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));
@@ -1425,9 +1425,9 @@ bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg, List
 				 * 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; 
+				/*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<<(*gtmp)[liste_voisin.at(id)]._index<<" ";
 				}
 				std::cout<<std::endl;*/
 				double poids_a = -1.;
@@ -1447,14 +1447,14 @@ bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg, List
 					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++){
@@ -1473,12 +1473,12 @@ bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg, List
 						}
 						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;	
+							index = id;
 							break;
 						}
 					}
@@ -1489,7 +1489,7 @@ bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg, List
 				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);
@@ -1512,10 +1512,10 @@ bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg, List
 				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
@@ -1530,10 +1530,10 @@ bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg, List
 				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)
@@ -1568,7 +1568,7 @@ bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg, List
 				 * alors on l'ajoute à la liste de correspondance des sommets et on
 				 * le verrouille
 				 */
-				//std::cout<<"Le sommet tiré est isolé "<<std::endl; 
+				//std::cout<<"Le sommet tiré est isolé "<<std::endl;
 				Entiers *couple = new Entiers();
 				couple->push_back(vertexs);
 				tableau_de_correspondance->push_back(couple);
@@ -1598,7 +1598,7 @@ bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg, List
 	 * 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);
 	}
@@ -1606,7 +1606,7 @@ bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg, List
 	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
@@ -1616,7 +1616,7 @@ bool contraction_HEM_mds_ameliore_KK(UnorientedGraph *g, Base_Graph &baseg, List
 
 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)
@@ -1633,7 +1633,7 @@ bool contraction_Random_Maching(UnorientedGraph *g, Base_Graph &baseg, ListEntie
 	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
@@ -1761,7 +1761,7 @@ bool contraction_Random_Maching(UnorientedGraph *g, Base_Graph &baseg, ListEntie
 	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
@@ -1954,7 +1954,7 @@ double Cut_one_cluster(const Entiers &cluster, UnorientedGraph &g, std::string n
 		double vol = Cluster_Weight(g,cluster);
 		return (cpt/2.)/vol;
 	}
-	
+
 	/*Vérification de la formule : doute sur le /2.*/
 }
 
@@ -2163,7 +2163,7 @@ OrientedGraphs Graph_Partition(const EntiersEntiers& Partition,
 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){
@@ -2412,7 +2412,7 @@ int decimal(int valeur){
 		break;
 		case 100000000 ... 999999999 : res = 8;
 		break;
-	default : 
+	default :
 		std::cout<<"L'interval n'est pas de taille suffisante"<<std::endl;
 		break;
 	}
@@ -2420,44 +2420,44 @@ int decimal(int valeur){
 }
 
 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; 
+	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++){
@@ -2465,14 +2465,16 @@ void Graph_constructor_txt(const char* text, OrientedGraph * Og){
 	double poids;
 	std::string txt;
 	fichier >> poids >> txt ;
-	DynamicsType type;
+	int type;
 	if(txt == "NORMAL_PIXEL"){
-		type = NORMAL_PIXEL; 
+		type = 1;
+		// type = NORMAL_PIXEL;
 	}else{
-		type = TOP_PIXEL;
+		type = 0;
+		// type = TOP_PIXEL;
 	}
 	(*Og)[vect_vertex.at(cpt)] = VertexProperties(cpt, poids, type);
-	//std::cout << poids << std::endl; 
+	//std::cout << poids << std::endl;
 	int tmp = decimal(floor(poids)) + 17;
 	deplacement_sup += tmp;
 	cpt++;
@@ -2482,7 +2484,7 @@ void Graph_constructor_txt(const char* text, OrientedGraph * Og){
 }
 
 void Text_generator_graph(const char *texte, OrientedGraph *go){
-	
+
 	bool found;
 	edge_to e1;
 	std::ofstream fichier (texte, std::ios::out);
@@ -2502,17 +2504,17 @@ void Text_generator_graph(const char *texte, OrientedGraph *go){
     }
     tie(vertexIto, vertexEndo) = vertices(*go);
     for (; vertexIto != vertexEndo; ++vertexIto) {
-		if(((*go)[*vertexIto]._weight - floor((*go)[*vertexIto]._weight)) == 0 && (*go)[*vertexIto]._type == TOP_PIXEL){
+        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 == NORMAL_PIXEL){
+		}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 == TOP_PIXEL){
+		}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();
 }
 
@@ -2520,7 +2522,7 @@ double Diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition, int p
 	double Dif;
 	double Int = 0.;
 	double Ext = 0.;
-	
+
 	edge_t e1;
     bool found;
 
@@ -2533,19 +2535,19 @@ double Diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Partition, int p
 			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;
 
@@ -2556,13 +2558,13 @@ double Diff_cut_ratio_bissection(UnorientedGraph *g, Entiers *part, int node, st
 			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++){
@@ -2572,8 +2574,8 @@ std::vector<std::vector<int>> Vector_diff_cut_ratio(UnorientedGraph *g, const En
 				std::pair<double, int> D;
 				D.first =  gain_d;
 				D.second = Partition.at(i)->at(j);
-				D_vector.push_back(D);		
-			}	
+				D_vector.push_back(D);
+			}
 		}
 		sort(D_vector.begin(),D_vector.end());
 		std::reverse(D_vector.begin(),D_vector.end());
@@ -2583,7 +2585,7 @@ std::vector<std::vector<int>> Vector_diff_cut_ratio(UnorientedGraph *g, const En
 		}
 		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<<"* ";
@@ -2592,7 +2594,7 @@ std::vector<std::vector<int>> Vector_diff_cut_ratio(UnorientedGraph *g, const En
 		}
 		std::cout<<std::endl;
 	}*/
-	
+
 	return Diff_vector;
 
 }
@@ -2608,15 +2610,15 @@ std::vector<int> Vector_diff_cut_ratio_2(UnorientedGraph *g, const EntiersEntier
 				std::pair<double, int> D;
 				D.first =  gain_d;
 				D.second = Partition.at(i)->at(j);
-				D_vector.push_back(D);		
-			}	
+				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<<"* ";
@@ -2629,14 +2631,14 @@ std::vector<int> Vector_diff_cut_ratio_2(UnorientedGraph *g, const EntiersEntier
 		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;
@@ -2649,16 +2651,16 @@ void Modif_vector_diff_cut_ratio_2(UnorientedGraph *g, const EntiersEntiers &Par
 			std::pair<double, int> D;
 			D.first =  gain_d;
 			D.second = *neighbourIt;
-			D_vector.push_back(D);		
+			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++){
@@ -2668,9 +2670,9 @@ void Modif_vector_diff_cut_ratio_2(UnorientedGraph *g, const EntiersEntiers &Par
 	//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)<<" ";
 	}
@@ -2678,7 +2680,7 @@ void Modif_vector_diff_cut_ratio_2(UnorientedGraph *g, const EntiersEntiers &Par
 }
 
 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);
@@ -2687,8 +2689,8 @@ void Modif_vector_diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Parti
 			std::pair<double, int> D;
 			D.first =  gain_d;
 			D.second = Partition.at(recalcul1)->at(j);
-			D_vector.push_back(D);		
-		}	
+			D_vector.push_back(D);
+		}
 	}
 	sort(D_vector.begin(),D_vector.end());
 	std::reverse(D_vector.begin(),D_vector.end());
@@ -2697,7 +2699,7 @@ void Modif_vector_diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Parti
 		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);
@@ -2706,8 +2708,8 @@ void Modif_vector_diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Parti
 			std::pair<double, int> D;
 			D.first =  gain_d;
 			D.second = Partition.at(recalcul2)->at(j);
-			D_vector2.push_back(D);		
-		}	
+			D_vector2.push_back(D);
+		}
 	}
 	sort(D_vector2.begin(),D_vector2.end());
 	std::reverse(D_vector2.begin(),D_vector2.end());
@@ -2716,7 +2718,7 @@ void Modif_vector_diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Parti
 		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<<"* ";
@@ -2725,12 +2727,12 @@ void Modif_vector_diff_cut_ratio(UnorientedGraph *g, const EntiersEntiers &Parti
 		}
 		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;
@@ -2740,16 +2742,16 @@ void Affinache_gain_diff(UnorientedGraph *g, EntiersEntiers &Partition, double &
 		}*/
 		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() && 
+				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;
@@ -2765,7 +2767,7 @@ void Affinache_gain_diff(UnorientedGraph *g, EntiersEntiers &Partition, double &
 							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);
@@ -2777,13 +2779,13 @@ void Affinache_gain_diff(UnorientedGraph *g, EntiersEntiers &Partition, double &
 						    }
 								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;
@@ -2798,7 +2800,7 @@ void Affinache_gain_diff(UnorientedGraph *g, EntiersEntiers &Partition, double &
 						i = 0;
 					}else{
 						i++;
-					}			
+					}
 				}
 			}
 		}
@@ -2808,14 +2810,14 @@ void Affinache_gain_diff(UnorientedGraph *g, EntiersEntiers &Partition, double &
 
 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){
@@ -2835,7 +2837,7 @@ void Affinache_gain_diff_2(UnorientedGraph *g, EntiersEntiers &Partition, double
 						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);
@@ -2847,13 +2849,13 @@ void Affinache_gain_diff_2(UnorientedGraph *g, EntiersEntiers &Partition, double
 					    }
 							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;
@@ -2884,15 +2886,15 @@ double Gain_ratio(UnorientedGraph *g,const EntiersEntiers &Partition, int in, in
 	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){
@@ -2907,7 +2909,7 @@ double Gain_ratio(UnorientedGraph *g,const EntiersEntiers &Partition, int in, in
 			}
 		}
 	}
-	
+
 	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){
@@ -2927,17 +2929,17 @@ double Gain_ratio(UnorientedGraph *g,const EntiersEntiers &Partition, int in, in
 			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 !!!*/
@@ -2948,15 +2950,15 @@ double Modif_ratio_cut(UnorientedGraph *g,Entiers *Ss, Entiers *Sd, int node, do
 	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);
@@ -2970,7 +2972,7 @@ double Modif_ratio_cut(UnorientedGraph *g,Entiers *Ss, Entiers *Sd, int node, do
 			}
 		}
 	}
-	
+
 	/*for(uint i = 0; i < Sd->size(); i++){
 		tie(neighbourIt, neighbourEnd) = adjacent_vertices(Sd->at(i), *g);
 		for (; neighbourIt != neighbourEnd; ++neighbourIt){
@@ -2990,14 +2992,14 @@ double Modif_ratio_cut(UnorientedGraph *g,Entiers *Ss, Entiers *Sd, int node, do
 			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;
 }
@@ -3011,15 +3013,15 @@ EntiersEntiers Spectral_Partition(const char* text){
 		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;
@@ -3040,7 +3042,7 @@ EntiersEntiers Spectral_Partition(const char* text){
 	}else{
 		std::cerr << "Impossible d'ouvrir le fichier dans Spectral_Partition !" << std::endl;
 	}
-	
+
 	return(Partition);
 }
 
@@ -3050,7 +3052,7 @@ void Adjacent_Matrix_Txt(UnorientedGraph *g, const char* text){
 		tie(vertexIt, vertexEnd) = vertices(*g);
 		edge_t e1;
 		bool found;
-		
+
 		for (; vertexIt != vertexEnd; ++vertexIt) {
 			int cpt = 0;
 			tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
@@ -3071,20 +3073,20 @@ void Adjacent_Matrix_Txt(UnorientedGraph *g, const char* text){
 				}
 			}
 			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);  
+	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;
@@ -3093,9 +3095,9 @@ void Weight_Matrix_Txt(UnorientedGraph *g, const char* text){
 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;   
+    fichier2<<"digraph G {"<<std::endl;
     tie(vertexIto, vertexEndo) = vertices(*go);
     for (; vertexIto != vertexEndo; ++vertexIto) {
     	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
@@ -3108,19 +3110,19 @@ void Plot_OrientedGraph(OrientedGraph *go, const char* text){
 					<<(*go)[e1]._weight
 					<<", fontsize=10, fontcolor= blue];"<<std::endl;
     	}
-	} 
-    
-	fichier2<<"}";	
+	}
+
+	fichier2<<"}";
 	fichier2.close();
-	
+
 }
 
-void Plot_UnorientedGraph(UnorientedGraph *g, const char* text){	
+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;   
+	GRAPH2<<"graph G {"<<std::endl;
 	tie(vertexIt, vertexEnd) = vertices(*g);
 	for (; vertexIt != vertexEnd; ++vertexIt) {
 		tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,*g);
@@ -3130,19 +3132,19 @@ void Plot_UnorientedGraph(UnorientedGraph *g, const char* text){
 				GRAPH2<<(*g)[*vertexIt]._index<<" -- "<<(*g)[*neighbourIt]._index<<" [label="<<(*g)[e1]._weight<<", fontsize=10, fontcolor= blue];"<<std::endl;
 			}
 		}
-	}  
+	}
 
-	GRAPH2<<"}";	
+	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;   
+		GRAPH2<<"graph G {"<<std::endl;
 		tie(vertexIt, vertexEnd) = vertices(*g);
 		for (; vertexIt != vertexEnd; ++vertexIt) {
 			tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,*g);
@@ -3151,8 +3153,8 @@ void Plot_UnorientedGraph_All(UnorientedGraph *g, const EntiersEntiers &Partitio
 					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];");
@@ -3183,7 +3185,7 @@ void Plot_UnorientedGraph_All(UnorientedGraph *g, const EntiersEntiers &Partitio
 			}
 		}
 
-		GRAPH2<<"}";	
+		GRAPH2<<"}";
 		GRAPH2.close();
 	}else{
 		std::cout<<"Error : Le nombre de couleur est insuffisant pour réaliser l'affichange"<<std::endl;
@@ -3193,7 +3195,7 @@ void Plot_UnorientedGraph_All(UnorientedGraph *g, const EntiersEntiers &Partitio
 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];");
@@ -3212,9 +3214,9 @@ void Plot_OrientedGraph_All(OrientedGraph *go, const EntiersEntiers &Partition,
 		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;   
+	    fichier2<<"digraph G {"<<std::endl;
 	    tie(vertexIto, vertexEndo) = vertices(*go);
 	    for (; vertexIto != vertexEndo; ++vertexIto) {
 	    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
@@ -3224,19 +3226,19 @@ void Plot_OrientedGraph_All(OrientedGraph *go, const EntiersEntiers &Partition,
 					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<<"}";
 		fichier2.close();
-		
+
 	}else{
 		std::cout<<"Error : Le nombre de couleur est insuffisant pour réaliser l'affichange"<<std::endl;
 	}
@@ -3250,7 +3252,7 @@ void Affichage_OrientedGraph(OrientedGraph *go){
     	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
     			*go);
     	for (; neighbourIto != neighbourEndo; ++neighbourIto){
-    		std::cout<<(*go)[*neighbourIto]._index<<" ";	
+    		std::cout<<(*go)[*neighbourIto]._index<<" ";
     	}
     	std::cout<<std::endl;
     }
@@ -3264,7 +3266,7 @@ void Affichage_UnorientedGraph(UnorientedGraph *g){
     	tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
     			*g);
     	for (; neighbourIt != neighbourEnd; ++neighbourIt){
-    		std::cout<<(*g)[*neighbourIt]._index<<" ";	
+    		std::cout<<(*g)[*neighbourIt]._index<<" ";
     	}
     	std::cout<<std::endl;
     }
@@ -3275,7 +3277,7 @@ 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);
@@ -3286,25 +3288,25 @@ double Total_weight_edges(UnorientedGraph *g){
 				}
 		}
 	}
-	
+
 	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, NORMAL_PIXEL);
-		}	
-		
+			(*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);
@@ -3313,20 +3315,20 @@ void Merge_Boost_Graph(OrientedGraph *go1, OrientedGraph *go2, std::vector<std::
 				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, NORMAL_PIXEL);
-		}	
-		
+			(*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);
@@ -3335,19 +3337,19 @@ void Merge_Boost_Graph(OrientedGraph *go1, OrientedGraph *go2, std::vector<std::
 				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);
@@ -3357,12 +3359,12 @@ Entiers Random_Sort_Vector(uint size){
 		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);
@@ -3372,16 +3374,16 @@ Entiers Random_Sort_Vector2(uint min, uint size){
 		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);
 }
 

+ 3 - 1
src/tests/multithreading/CMakeLists.txt

@@ -24,4 +24,6 @@ ADD_EXECUTABLE(pdevs-multithreading-main graph_manager.hpp main.cpp
 TARGET_LINK_LIBRARIES(pdevs-multithreading-main partitioning
   ${CMAKE_THREAD_LIBS_INIT}
   ${Boost_SYSTEM_LIBRARY}
-  ${Boost_TIMER_LIBRARY})
+  ${Boost_TIMER_LIBRARY})
+
+ADD_SUBDIRECTORY(lifegame)

+ 18 - 0
src/tests/multithreading/lifegame/CMakeLists.txt

@@ -0,0 +1,18 @@
+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-multithreading-lifegame-main graph_manager.hpp main.cpp
+  models.hpp)
+
+TARGET_LINK_LIBRARIES(pdevs-multithreading-lifegame-main partitioning
+  ${CMAKE_THREAD_LIBS_INIT}
+  ${Boost_SYSTEM_LIBRARY}
+  ${Boost_TIMER_LIBRARY})

+ 149 - 0
src/tests/multithreading/lifegame/graph_builder.hpp

@@ -0,0 +1,149 @@
+/**
+ * @file tests/multithreading/lifegame/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_MULTITHREADING_LIFEGAME_GRAPH_BUILDER_HPP
+#define TESTS_MULTITHREADING_LIFEGAME_GRAPH_BUILDER_HPP 1
+
+#include <tests/boost_graph/graph_defs.hpp>
+#include <tests/boost_graph/partitioning/gggp.hpp>
+
+using namespace paradevs::tests::boost_graph;
+
+namespace paradevs { namespace tests {
+        namespace multithreading { namespace lifegame {
+
+const int NCOLUMNS = 10;
+const int NLINES = 10;
+
+class GraphBuilder
+{
+public:
+    GraphBuilder(int cluster_number) :
+        _cluster_number(cluster_number)
+    { }
+
+    void build(OrientedGraphs& graphs,
+               InputEdgeList& input_edges,
+               OutputEdgeList& output_edges,
+               Connections& parent_connections)
+    {
+        std::vector < std::string > parameters = {
+            "HEM", "rande", "diff", "ratio"
+        };
+        // std::vector < std::string > parameters = {
+        //     "HEM", "gggp", "diff", "ratio"
+        // };
+
+        bool contraction_coef_flag = false;
+        uint contraction_coef = 20;
+        uint cluster_number = _cluster_number;
+        OrientedGraph go;
+        Edges edge_partie;
+        Connections connections;
+
+        generate(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)
+    {
+        std::vector < OrientedGraph::vertex_descriptor > vertices;
+
+        for (int i = 0; i < NLINES; ++i) {
+            for (int j = 0; j < NCOLUMNS; ++j) {
+                vertices.push_back(boost::add_vertex(g));
+                g[vertices.back()] = VertexProperties(i * NCOLUMNS + j, 1., 0);
+            }
+        }
+
+        for (int i = 0; i < NLINES; ++i) {
+            for (int j = 0; j < NCOLUMNS; ++j) {
+                int index = i * NCOLUMNS + j;
+
+                if (i > 0) {
+                    boost::add_edge(vertices[(i - 1) * NCOLUMNS + j],
+                                    vertices[index], 1., g);
+                }
+                if (i < NLINES - 1) {
+                    boost::add_edge(vertices[(i + 1) * NCOLUMNS + j],
+                                    vertices[index], 1., g);
+                }
+                if (j > 0) {
+                    boost::add_edge(vertices[i * NCOLUMNS + j - 1],
+                                    vertices[index], 1., g);
+                }
+                if (j < NCOLUMNS - 1) {
+                    boost::add_edge(vertices[i * NCOLUMNS + j + 1],
+                                    vertices[index], 1., g);
+                }
+            }
+        }
+
+        // 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;
+};
+
+} } } } // namespace paradevs tests multithreading lifegame
+
+#endif

+ 367 - 132
src/tests/multithreading/lifegame/graph_manager.hpp

@@ -28,6 +28,7 @@
 #define TESTS_MULTITHREADING_LIFEGAME_GRAPH_MANAGER_HPP 1
 
 #include <tests/multithreading/lifegame/models.hpp>
+#include <tests/multithreading/lifegame/graph_builder.hpp>
 
 #include <paradevs/kernel/pdevs/multithreading/Coordinator.hpp>
 #include <paradevs/kernel/pdevs/GraphManager.hpp>
@@ -36,82 +37,199 @@
 namespace paradevs { namespace tests {
         namespace multithreading { namespace lifegame {
 
-template < class SchedulerHandle >
-class S1GraphManager :
-        public paradevs::pdevs::GraphManager < common::DoubleTime,
-                                               SchedulerHandle >
+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:
-    S1GraphManager(common::Coordinator < common::DoubleTime,
-                                         SchedulerHandle >* coordinator,
-                   const paradevs::common::NoParameters& parameters) :
-        paradevs::pdevs::GraphManager < common::DoubleTime,
-                                        SchedulerHandle >(coordinator,
-                                                          parameters),
-        a("a1", common::NoParameters()), b("b1", common::NoParameters())
+    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)
     {
-        S1GraphManager < SchedulerHandle >::add_child(&a);
-        S1GraphManager < SchedulerHandle >::add_child(&b);
+        OrientedGraph::vertex_iterator vertexIt, vertexEnd;
 
-        a.add_out_port("out");
-        b.add_in_port("in");
-        b.add_out_port("out");
-        coordinator->add_out_port("out");
+        boost::tie(vertexIt, vertexEnd) = boost::vertices(g);
+        for (; vertexIt != vertexEnd; ++vertexIt) {
+            std::ostringstream ss;
+            int i = g[*vertexIt]._index / NCOLUMNS;
+            int j = g[*vertexIt]._index - i * NCOLUMNS;
+            int neighbour_number = 0;
 
-        S1GraphManager < SchedulerHandle >::add_link(&a, "out", &b, "in");
-        S1GraphManager < SchedulerHandle >::add_link(&b, "out",
-                                                     coordinator, "out");
+            if (i > 0) {
+                ++neighbour_number;
+            }
+            if (i < NLINES - 1) {
+                ++neighbour_number;
+            }
+            if (j > 0) {
+                ++neighbour_number;
+            }
+            if (j < NCOLUMNS - 1) {
+                ++neighbour_number;
+            }
+
+            ss << "a" << g[*vertexIt]._index;
+            _simulators[g[*vertexIt]._index] =
+                new pdevs::Simulator <
+                    common::DoubleTime,
+                Cell,
+                CellParameters >(ss.str(),
+                                 CellParameters(neighbour_number));
+            _simulators[g[*vertexIt]._index]->add_out_port("out");
+            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");
+            }
+        }
     }
 
-    void init()
-    { }
+protected:
+    typedef std::map < int, pdevs::Simulator <
+                                common::DoubleTime,
+                                Cell,
+                                CellParameters >* > Simulators;
 
-    void start(common::DoubleTime::type /* t */)
-    { }
+    Simulators _simulators;
+};
 
-    void transition(
-        const common::Models < common::DoubleTime,
-                               pdevs::SchedulerHandle >& /* receivers */,
-        common::DoubleTime::type /* t */)
-    { }
+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);
 
-    virtual ~S1GraphManager()
-    { }
+        // input
+        for (Edges::const_iterator it = parameters._input_edges.begin();
+             it != parameters._input_edges.end(); ++it) {
+            std::ostringstream ss_in;
 
-private:
-    paradevs::pdevs::Simulator < common::DoubleTime,
-                                 pdevs::A < SchedulerHandle >,
-                                 SchedulerHandle > a;
-    paradevs::pdevs::Simulator < common::DoubleTime,
-                                 pdevs::B < SchedulerHandle >,
-                                 SchedulerHandle > b;
+            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()
+    { }
 };
 
-template < class SchedulerHandle >
-class S2GraphManager :
-        public paradevs::pdevs::GraphManager < common::DoubleTime,
-                                               SchedulerHandle >
+class ParallelBuiltFlatGraphManager :
+        public FlatGraphManager < GraphParameters >
 {
 public:
-    S2GraphManager(common::Coordinator < common::DoubleTime,
-                                         SchedulerHandle >* coordinator,
-                   const paradevs::common::NoParameters& parameters) :
-        paradevs::pdevs::GraphManager < common::DoubleTime,
-                                        SchedulerHandle >(coordinator,
-                                                          parameters),
-        a("a2", common::NoParameters()), b("b2", common::NoParameters())
+    ParallelBuiltFlatGraphManager(
+        common::Coordinator < common::DoubleTime >* coordinator,
+        const GraphParameters& parameters) :
+        FlatGraphManager < GraphParameters >(
+            coordinator, parameters)
     {
-        S2GraphManager < SchedulerHandle >::add_child(&a);
-        S2GraphManager < SchedulerHandle >::add_child(&b);
+        ParallelBuiltFlatGraphManager::build_flat_graph(
+            parameters._graph, parameters._input_edges);
 
-        a.add_in_port("in");
-        a.add_out_port("out");
-        b.add_in_port("in");
-        coordinator->add_in_port("in");
+        // input
+        for (Edges::const_iterator it = parameters._input_edges.begin();
+             it != parameters._input_edges.end(); ++it) {
+            std::ostringstream ss_in;
 
-        S2GraphManager < SchedulerHandle >::add_link(&a, "out", &b, "in");
-        S2GraphManager < SchedulerHandle >::add_link(coordinator, "in",
-                                                     &a, "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()
@@ -121,108 +239,225 @@ public:
     { }
 
     void transition(
-        const common::Models < common::DoubleTime,
-                               pdevs::SchedulerHandle >& /* receivers */,
+        const common::Models < common::DoubleTime >& /* receivers */,
         common::DoubleTime::type /* t */)
     { }
 
-    virtual ~S2GraphManager()
+    virtual ~ParallelBuiltFlatGraphManager()
+    { }
+};
+
+struct GraphManagerParameters
+{
+    GraphManagerParameters(int cluster_number) : cluster_number(cluster_number)
     { }
 
+    int cluster_number;
+};
+
+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.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:
-    paradevs::pdevs::Simulator < common::DoubleTime,
-                                 pdevs::A < SchedulerHandle >,
-                                 SchedulerHandle > a;
-    paradevs::pdevs::Simulator < common::DoubleTime,
-                                 pdevs::B < SchedulerHandle >,
-                                 SchedulerHandle > b;
+    typedef paradevs::pdevs::Coordinator <
+        common::DoubleTime,
+        BuiltFlatGraphManager,
+        common::NoParameters,
+        GraphParameters
+    > Coordinator;
+    typedef std::vector < Coordinator* > Coordinators;
+
+    Coordinators _coordinators;
 };
 
-class RootGraphManager :
-        public paradevs::pdevs::GraphManager < common::DoubleTime,
-                                               pdevs::SchedulerHandle >
+class ParallelHierarchicalGraphManager :
+                public paradevs::pdevs::GraphManager < common::DoubleTime,
+                                                       GraphManagerParameters >
 {
 public:
-    RootGraphManager(
-        common::Coordinator < common::DoubleTime,
-                              pdevs::SchedulerHandle >* coordinator,
-        const paradevs::common::NoParameters& parameters) :
+    ParallelHierarchicalGraphManager(
+        common::Coordinator < common::DoubleTime >* coordinator,
+        const GraphManagerParameters& parameters) :
         paradevs::pdevs::GraphManager < common::DoubleTime,
-                                        pdevs::SchedulerHandle >(
-                                            coordinator, parameters),
-        S1("S1", paradevs::common::NoParameters(),
-           paradevs::common::NoParameters()),
-        S2("S2", paradevs::common::NoParameters(),
-           paradevs::common::NoParameters())
+                                        GraphManagerParameters >(
+                                            coordinator, parameters)
     {
-        add_child(&S1);
-        add_child(&S2);
+        GraphBuilder   graph_builder(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());
+            }
+        }
+    }
 
-        add_link(&S1, "out", &S2, "in");
+    virtual ~ParallelHierarchicalGraphManager()
+    {
+        for (typename Coordinators::const_iterator it = _coordinators.begin();
+             it != _coordinators.end(); ++it) {
+            delete *it;
+        }
     }
 
     void init()
     {
-        S1.set_sender(
-            dynamic_cast < paradevs::pdevs::multithreading::Coordinator <
-                common::DoubleTime,
-                paradevs::common::scheduler::HeapScheduler <
-                    common::DoubleTime, pdevs::SchedulerHandle >,
-                pdevs::SchedulerHandle,
-                paradevs::tests::multithreading::RootGraphManager >*
-            >(get_coordinator())->get_sender());
-        S2.set_sender(
-            dynamic_cast < paradevs::pdevs::multithreading::Coordinator <
-                common::DoubleTime,
-                paradevs::common::scheduler::HeapScheduler <
-                    common::DoubleTime, pdevs::SchedulerHandle >,
-                pdevs::SchedulerHandle,
-                paradevs::tests::multithreading::RootGraphManager >*
-            >(get_coordinator())->get_sender());
+        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)
     {
-        S1.get_sender().send(
-            paradevs::pdevs::multithreading::start_message <
-                common::DoubleTime >(t));
-        S2.get_sender().send(
-            paradevs::pdevs::multithreading::start_message <
-                common::DoubleTime >(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,
-                                           pdevs::SchedulerHandle >& receivers,
-                    common::DoubleTime::type t)
+    void transition(const common::Models < common::DoubleTime >& receivers,
+                    paradevs::common::DoubleTime::type t)
     {
-        if (std::find(receivers.begin(), receivers.end(),
-                      &S1) != receivers.end()) {
-            S1.get_sender().send(
-                paradevs::pdevs::multithreading::transition_message <
-                    common::DoubleTime >(t));
-        }
-        if (std::find(receivers.begin(), receivers.end(),
-                      &S2) != receivers.end()) {
-            S2.get_sender().send(
-                paradevs::pdevs::multithreading::transition_message <
-                    common::DoubleTime >(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;
         }
     }
 
-    virtual ~RootGraphManager()
-    { }
-
 private:
-    paradevs::pdevs::multithreading::Coordinator <
-        common::DoubleTime,
-        pdevs::SchedulerType,
-        pdevs::SchedulerHandle,
-        S1GraphManager < pdevs::SchedulerHandle > > S1;
-    paradevs::pdevs::multithreading::Coordinator <
-        common::DoubleTime,
-        pdevs::SchedulerType,
-        pdevs::SchedulerHandle,
-        S2GraphManager < pdevs::SchedulerHandle > > S2;
+    typedef paradevs::pdevs::multithreading::Coordinator <
+      common::DoubleTime,
+      ParallelBuiltFlatGraphManager,
+      common::NoParameters,
+      GraphParameters
+    > ParallelCoordinator;
+    typedef std::vector < ParallelCoordinator* > Coordinators;
+
+    Coordinators _coordinators;
 };
 
 } } } } // namespace paradevs tests multithreading lifegame

+ 100 - 0
src/tests/multithreading/lifegame/main.cpp

@@ -0,0 +1,100 @@
+/**
+ * @file tests/multithreading/lifegame/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/multithreading/lifegame/graph_manager.hpp>
+#include <tests/multithreading/lifegame/models.hpp>
+
+#include <chrono>
+
+using namespace paradevs::common;
+using namespace std::chrono;
+using namespace paradevs::tests::multithreading::lifegame;
+
+double lifegame_monothreading()
+{
+    paradevs::common::RootCoordinator <
+        DoubleTime, paradevs::pdevs::Coordinator <
+            DoubleTime,
+            HierarchicalGraphManager,
+            paradevs::common::NoParameters,
+            GraphManagerParameters >
+        > rc(0, 10, "root", paradevs::common::NoParameters(),
+             GraphManagerParameters(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 lifegame_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(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 lifegame(int n)
+{
+    if (n == 1) {
+        std::cout << lifegame_monothreading() << std::endl;
+    } else {
+        std::cout << lifegame_multithreading(n) << std::endl;
+        // lifegame_multithreading(n);
+    }
+}
+
+int main(int argc, char** argv)
+{
+    if (argc > 1) {
+        lifegame(atoi(argv[1]));
+    }
+    return 0;
+}

+ 92 - 15
src/tests/multithreading/lifegame/models.hpp

@@ -34,60 +34,137 @@
 namespace paradevs { namespace tests {
         namespace multithreading { namespace lifegame {
 
+struct CellParameters
+{
+    CellParameters(int n) : neighbour_number(n)
+    { }
 
-template < class SchedulerHandle>
-class Cell :
-        public paradevs::pdevs::Dynamics < common::DoubleTime, SchedulerHandle >
+    int neighbour_number;
+};
+
+class Cell : public paradevs::pdevs::Dynamics < common::DoubleTime,
+                                                CellParameters >
 {
 public:
-    Cell(const std::string& name, const common::NoParameters& parameters) :
-        paradevs::pdevs::Dynamics < common::DoubleTime,
-                                    SchedulerHandle >(name, parameters)
+    Cell(const std::string& name, const CellParameters& parameters) :
+        paradevs::pdevs::Dynamics < common::DoubleTime, CellParameters >(
+            name, parameters),
+        _neighbour_number(parameters.neighbour_number)
     { }
     virtual ~Cell()
     { }
 
     void dint(typename common::DoubleTime::type t)
     {
+
+        // std::cout << t << " [" << get_name() << "] -> dint: "
+        //           << _phase << " => ";
+
+        if (_phase == SEND) {
+            _phase = WAIT;
+            _sigma = common::DoubleTime::infinity;
+        } else if (_phase == NEWSTATE) {
+            if (_state && (_true_neighbour_number < 2 ||
+                           _true_neighbour_number > 3)) {
+                _state = false;
+            } else if (not _state && (_true_neighbour_number == 3)) {
+                _state = true;
+            }
+            _phase  = SEND;
+            _sigma = 1;
+            _true_neighbour_number = 0;
+            _received = 0;
+        }
+
+        // std::cout << _phase << std::endl;
+
     }
 
     void dext(typename common::DoubleTime::type t,
               typename common::DoubleTime::type /* e */,
-              const common::Bag < common::DoubleTime, SchedulerHandle >& msgs)
+              const common::Bag < common::DoubleTime >& bag)
     {
+
+        // std::cout << t << " [" << get_name() << "] -> dext => "
+        //           << _received << " " << _phase << std::endl;
+
+        for (common::Bag < common::DoubleTime >::const_iterator it =
+                 bag.begin(); it != bag.end(); ++it) {
+            if (*(bool*)(it->get_content())) {
+                ++_true_neighbour_number;
+            }
+            ++_received;
+        }
+
+        if (_received == _neighbour_number) {
+            _phase = NEWSTATE;
+            _sigma = 0;
+        } else {
+            _phase = WAIT;
+            _sigma = common::DoubleTime::infinity;
+        }
+
+        // std::cout << t << " [" << get_name() << "] -> dext (AFTER) => "
+        //           << _received << " " << _phase << std::endl;
+
     }
 
     void dconf(typename common::DoubleTime::type t,
-               typename common::DoubleTime::type /* e */,
-               const common::Bag < common::DoubleTime, SchedulerHandle >& msgs)
+               typename common::DoubleTime::type e,
+               const common::Bag < common::DoubleTime >& bag)
     {
+
+        // std::cout << t << " [" << get_name() << "] -> dconf" << std::endl;
+
+        dext(t, e, bag);
     }
 
     typename common::DoubleTime::type start(typename common::DoubleTime::type t)
     {
+
+        // std::cout << t << " [" << get_name() << "] -> START" << std::endl;
+
+        _phase = SEND;
+        _sigma = 0;
+        _state = false;
+        _true_neighbour_number = 0;
+        _received = 0;
         return 0;
     }
 
     typename common::DoubleTime::type ta(
         typename common::DoubleTime::type t) const
-    {
-    }
+    { return _sigma; }
 
-    common::Bag < common::DoubleTime, SchedulerHandle > lambda(
+    common::Bag < common::DoubleTime > lambda(
         typename common::DoubleTime::type t) const
     {
-        common::Bag < common::DoubleTime, SchedulerHandle > msgs;
+        common::Bag < common::DoubleTime > bag;
+
+        if (_phase == SEND) {
 
-        return msgs;
+            // std::cout << t << " [" << get_name() << "] -> lambda"
+            //           << std::endl;
+
+            bag.push_back(common::ExternalEvent < common::DoubleTime >(
+                              "out", (void*)(&_state)));
+        }
+        return bag;
     }
 
     void observation(std::ostream& /* file */) const
     { }
 
 private:
-    enum Phase { INIT, IDLE, NEWSTATE };
+    enum Phase { SEND, WAIT, NEWSTATE };
+
+    unsigned int _neighbour_number;
 
     Phase _phase;
+    common::DoubleTime::type _sigma;
+    bool _state;
+    unsigned int _received;
+    unsigned int _true_neighbour_number;
 };
 
 } } } } // namespace paradevs tests multithreading lifegame

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

@@ -106,7 +106,7 @@ double grid_multithreading(int cluster_number)
             paradevs::tests::boost_graph::PartitioningParameters >
         > rc(0, 10, "root", paradevs::common::NoParameters(),
              paradevs::tests::boost_graph::PartitioningParameters(
-                 cluster_number, "gggp", 20, false, generator));
+                 cluster_number, "rand", 20, false, generator));
 
     steady_clock::time_point t1 = steady_clock::now();
 
@@ -190,6 +190,7 @@ void grid(int n)
         std::cout << grid_monothreading() << std::endl;
     } else {
         std::cout << grid_multithreading(n) << std::endl;
+        // grid_multithreading(n);
     }
 }
 
@@ -199,6 +200,7 @@ void tree(int n)
         std::cout << tree_monothreading() << std::endl;
     } else {
         std::cout << tree_multithreading(n) << std::endl;
+        // tree_multithreading(n);
     }
 }