Преглед на файлове

Modification partielle des algorithmes de partitionnement et nouveaux tests

Modification des fonctions Iter2l bissectionrec dans le but de réaliser un certain nombre de tirage
de sommets de départ dans le but de minimiser la fonction objectif choisie.

Ajout de la fonction objectif par coût de coupe ratio.

Ajout de la génération d'un fichier texte permettant de colorer le graphe en fonction des parties de
la partition (but visuel).

Ajout du générateur de graphe automatique, validation réalisée.
totofeh преди 10 години
родител
ревизия
a81004bb9a

+ 2 - 2
src/tests/CMakeLists.txt

@@ -11,8 +11,8 @@ LINK_DIRECTORIES(
 
 ADD_SUBDIRECTORY(boost_graph)
 ADD_SUBDIRECTORY(common)
-ADD_SUBDIRECTORY(corsen)
+#ADD_SUBDIRECTORY(corsen)
 ADD_SUBDIRECTORY(dtss)
 ADD_SUBDIRECTORY(mixed)
 ADD_SUBDIRECTORY(multithreading)
-ADD_SUBDIRECTORY(pdevs)
+ADD_SUBDIRECTORY(pdevs)

+ 2 - 2
src/tests/boost_graph/CMakeLists.txt

@@ -10,7 +10,7 @@ LINK_DIRECTORIES(
   ${LIBXML_LIBRARY_DIR})
 
 # graph tests
-ADD_EXECUTABLE(graph-tests graph_builder.hpp graph_defs.hpp graph_manager.hpp
+ADD_EXECUTABLE(graph-tests graph_builder.hpp graph_generator.hpp graph_defs.hpp graph_manager.hpp
   graph_partitioning.hpp tests.cpp models.hpp)
 
 TARGET_LINK_LIBRARIES(graph-tests partitioning
@@ -19,4 +19,4 @@ TARGET_LINK_LIBRARIES(graph-tests partitioning
   ${LIBXML_LIBRARIES}
   ${GTHREAD_LIBRARIES})
 
-ADD_SUBDIRECTORY(partitioning)
+ADD_SUBDIRECTORY(partitioning)

+ 50 - 157
src/tests/boost_graph/graph_builder.hpp

@@ -28,6 +28,7 @@
 #define __TESTS_BOOST_GRAPH_GRAPH_BUILDER_HPP 1
 
 #include <tests/boost_graph/graph_defs.hpp>
+#include <tests/boost_graph/partitioning/graph_build.hpp>
 
 namespace paradevs { namespace tests { namespace boost_graph {
 
@@ -42,163 +43,7 @@ public:
                Connections& /* parent_connections */)
     {
         OrientedGraph graph;
-
-        OrientedGraph::vertex_descriptor v0 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v1 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v2 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v3 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v4 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v5 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v6 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v7 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v8 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v9 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v10 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v11 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v12 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v13 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v14 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v15 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v16 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v17 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v18 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v19 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v20 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v21 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v22 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v23 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v24 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v25 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v26 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v27 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v28 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v29 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v30 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v31 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v32 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v33 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v34 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v35 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v36 = boost::add_vertex(graph);
-        OrientedGraph::vertex_descriptor v37 = boost::add_vertex(graph);
-
-        boost::add_edge(v1, v0, 1., graph);
-        boost::add_edge(v2, v0, 1., graph);
-        boost::add_edge(v3, v0, 1., graph);
-        boost::add_edge(v1, v2, 1., graph);
-        boost::add_edge(v4, v1, 1., graph);
-        boost::add_edge(v5, v1, 1., graph);
-        boost::add_edge(v6, v1, 1., graph);
-        boost::add_edge(v6, v2, 1., graph);
-        boost::add_edge(v2, v3, 1., graph);
-        boost::add_edge(v9, v3, 1., graph);
-        boost::add_edge(v10, v3 , 1., graph);
-        boost::add_edge(v4, v5, 1., graph);
-        boost::add_edge(v5, v6, 1., graph);
-        boost::add_edge(v7, v4, 1., graph);
-        boost::add_edge(v8, v4, 1., graph);
-        boost::add_edge(v7, v8, 1., graph);
-        boost::add_edge(v9, v10 , 1., graph);
-        boost::add_edge(v8, v11, 1., graph);
-        boost::add_edge(v11, v4, 1., graph);
-        boost::add_edge(v12, v13, 1., graph);
-        boost::add_edge(v12, v7, 1., graph);
-        boost::add_edge(v13, v7, 1., graph);
-        boost::add_edge(v14, v15, 1., graph);
-        boost::add_edge(v14, v12, 1., graph);
-        boost::add_edge(v15, v16, 1., graph);
-        boost::add_edge(v15, v12, 1., graph);
-        boost::add_edge(v16, v17, 1., graph);
-        boost::add_edge(v16, v12, 1., graph);
-        boost::add_edge(v17, v12, 1., graph);
-        boost::add_edge(v18, v19, 1., graph);
-        boost::add_edge(v18, v8, 1., graph);
-        boost::add_edge(v19, v20, 1., graph);
-        boost::add_edge(v19, v8, 1., graph);
-        boost::add_edge(v20, v8, 1., graph);
-        boost::add_edge(v21, v22, 1., graph);
-        boost::add_edge(v21, v19, 1., graph);
-        boost::add_edge(v22, v23, 1., graph);
-        boost::add_edge(v22, v19, 1., graph);
-        boost::add_edge(v23, v19, 1., graph);
-        boost::add_edge(v24, v25, 1., graph);
-        boost::add_edge(v24, v6, 1., graph);
-        boost::add_edge(v25, v6, 1., graph);
-        boost::add_edge(v26, v11, 1., graph);
-        boost::add_edge(v26, v27, 1., graph);
-        boost::add_edge(v26, v24, 1., graph);
-        boost::add_edge(v27, v24, 1., graph);
-        boost::add_edge(v28, v25, 1., graph);
-        boost::add_edge(v29, v27, 1., graph);
-        boost::add_edge(v29, v28, 1., graph);
-        boost::add_edge(v30, v27, 1., graph);
-        boost::add_edge(v30, v28, 1., graph);
-        boost::add_edge(v31, v32, 1., graph);
-        boost::add_edge(v31, v10, 1., graph);
-        boost::add_edge(v32, v33, 1., graph);
-        boost::add_edge(v32, v10, 1., graph);
-        boost::add_edge(v33, v10, 1., graph);
-        boost::add_edge(v34, v31, 1., graph);
-        boost::add_edge(v34, v35, 1., graph);
-        boost::add_edge(v35, v31, 1., graph);
-        boost::add_edge(v35, v32, 1., graph);
-        boost::add_edge(v36, v32, 1., graph);
-        boost::add_edge(v36, v37, 1., graph);
-        boost::add_edge(v36, v33, 1., graph);
-        boost::add_edge(v37, v33, 1., graph);
-
-        /*graph[v6] = VertexProperties(6, 1., NORMAL_PIXEL);
-        graph[v8] = VertexProperties(8, 1., NORMAL_PIXEL);
-        graph[v10] = VertexProperties(10, 1., NORMAL_PIXEL);
-        graph[v0] = VertexProperties(0, 1., NORMAL_PIXEL);
-        graph[v1] = VertexProperties(1, 1., NORMAL_PIXEL);
-        graph[v2] = VertexProperties(2, 1., NORMAL_PIXEL);
-        graph[v3] = VertexProperties(3, 1., NORMAL_PIXEL);
-        graph[v4] = VertexProperties(4, 1., NORMAL_PIXEL);
-        graph[v5] = VertexProperties(5, 1., NORMAL_PIXEL);
-        graph[v7] = VertexProperties(7, 1., TOP_PIXEL);
-        graph[v9] = VertexProperties(9, 1., TOP_PIXEL);*/
-
-        graph[v6] = VertexProperties(6, 2.5, NORMAL_PIXEL);
-        graph[v8] = VertexProperties(8, 2., NORMAL_PIXEL);
-        graph[v10] = VertexProperties(10, 2.5, NORMAL_PIXEL);
-        graph[v0] = VertexProperties(0, 4, NORMAL_PIXEL);
-        graph[v1] = VertexProperties(1, 3, NORMAL_PIXEL);
-        graph[v2] = VertexProperties(2, 3, NORMAL_PIXEL);
-        graph[v3] = VertexProperties(3, 3, NORMAL_PIXEL);
-        graph[v4] = VertexProperties(4, 2.5, NORMAL_PIXEL);
-        graph[v5] = VertexProperties(5, 2.5, NORMAL_PIXEL);
-        graph[v7] = VertexProperties(7, 2., NORMAL_PIXEL);
-        graph[v9] = VertexProperties(9, 2.5, TOP_PIXEL);
-        graph[v11] = VertexProperties(11, 2, NORMAL_PIXEL);
-        graph[v12] = VertexProperties(12, 1.5, NORMAL_PIXEL);
-        graph[v13] = VertexProperties(13, 1.5, NORMAL_PIXEL);
-        graph[v14] = VertexProperties(14, 1, TOP_PIXEL);
-        graph[v15] = VertexProperties(15, 1, NORMAL_PIXEL);
-        graph[v16] = VertexProperties(16, 1, NORMAL_PIXEL);
-        graph[v17] = VertexProperties(17, 1, NORMAL_PIXEL);
-        graph[v18] = VertexProperties(18, 1.5, TOP_PIXEL);
-        graph[v19] = VertexProperties(19, 1.5, NORMAL_PIXEL);
-        graph[v20] = VertexProperties(20, 1.5, NORMAL_PIXEL);
-        graph[v21] = VertexProperties(21, 1, TOP_PIXEL);
-        graph[v22] = VertexProperties(22, 1, NORMAL_PIXEL);
-        graph[v23] = VertexProperties(23, 1, NORMAL_PIXEL);
-        graph[v24] = VertexProperties(24, 2, NORMAL_PIXEL);
-        graph[v25] = VertexProperties(25, 2, NORMAL_PIXEL);
-        graph[v26] = VertexProperties(26, 1.5, TOP_PIXEL);
-        graph[v27] = VertexProperties(27, 1.5, NORMAL_PIXEL);
-        graph[v28] = VertexProperties(28, 1.5, NORMAL_PIXEL);
-        graph[v29] = VertexProperties(29, 1, TOP_PIXEL);
-        graph[v30] = VertexProperties(30, 1, TOP_PIXEL);
-        graph[v31] = VertexProperties(31, 2, NORMAL_PIXEL);
-        graph[v32] = VertexProperties(32, 2, NORMAL_PIXEL);
-        graph[v33] = VertexProperties(33, 2, NORMAL_PIXEL);
-        graph[v34] = VertexProperties(34, 1.5, TOP_PIXEL);
-        graph[v35] = VertexProperties(35, 1.5, NORMAL_PIXEL);
-        graph[v36] = VertexProperties(36, 1.5, TOP_PIXEL);
-        graph[v37] = VertexProperties(37, 1.5, NORMAL_PIXEL);
-
-
+		build_graph(graph, 38);
         graphs.push_back(graph);
     }
 };
@@ -461,6 +306,54 @@ public:
     }
 };
 
+class CorsenFlatGraphBuilder
+{
+public:
+    CorsenFlatGraphBuilder()
+    { }
+
+    void build(OrientedGraphs& graphs, InputEdgeList& /* input_edges */,
+               OutputEdgeList& /* output_edges */,
+               Connections& /* parent_connections */)
+    {
+        OrientedGraph graph;
+
+        //build_corsen_graph(graph);
+        graphs.push_back(graph);
+    }
+};
+
+class RandomFlatGraphBuilder
+{
+public:
+    RandomFlatGraphBuilder()
+    { }
+
+    void build(OrientedGraphs& graphs, InputEdgeList& ,
+               OutputEdgeList& ,
+               Connections& )
+    {
+		/*
+		 * *** Graphe créé différent du graphe obtenu dans graph_partitioning ! Solution ? *** 
+		 */
+		 
+        OrientedGraph graph;
+        unsigned int edge_number = 2000;
+        std::vector<int> levels;
+        levels.push_back(4);
+        levels.push_back(3);
+        levels.push_back(2);
+        unsigned int source_number = 5;
+        unsigned int min_neigh = 2;
+        unsigned int max_neigh = 4;
+
+        build_generator_graph(&graph,edge_number,source_number,min_neigh,max_neigh,levels);
+        graphs.push_back(graph);
+    }
+
+};
+
+
 } } } // namespace paradevs tests boost_graph
 
 #endif

+ 10 - 6
src/tests/boost_graph/graph_manager.hpp

@@ -405,12 +405,13 @@ struct PartitioningParameters
     std::string partitioning_method_name;
     int         contraction_coef;
     bool        contraction_coef_flag;
-
+	GraphGenerator* generator;
+	
     PartitioningParameters(int cn,
                            const std::string& pmn,
-                           int cc, bool ccf) :
+                           int cc, bool ccf, GraphGenerator* generator) :
         cluster_number(cn), partitioning_method_name(pmn),
-        contraction_coef(cc), contraction_coef_flag(ccf)
+        contraction_coef(cc), contraction_coef_flag(ccf), generator(generator)
     { }
 };
 
@@ -432,7 +433,8 @@ public:
         GraphBuilder graph_builder(parameters.cluster_number,
                                    parameters.partitioning_method_name,
                                    parameters.contraction_coef,
-                                   parameters.contraction_coef_flag);
+                                   parameters.contraction_coef_flag,
+								   parameters.generator);
         OrientedGraphs graphs;
         InputEdgeList  input_edges;
         OutputEdgeList output_edges;
@@ -534,7 +536,8 @@ public:
         GraphBuilder   graph_builder(parameters.cluster_number,
                                      parameters.partitioning_method_name,
                                      parameters.contraction_coef,
-                                     parameters.contraction_coef_flag);
+                                     parameters.contraction_coef_flag,
+                                     parameters.generator);
         OrientedGraphs graphs;
         InputEdgeList  input_edges;
         OutputEdgeList output_edges;
@@ -626,7 +629,8 @@ public:
         GraphBuilder   graph_builder(parameters.cluster_number,
                                      parameters.partitioning_method_name,
                                      parameters.contraction_coef,
-                                     parameters.contraction_coef_flag);
+                                     parameters.contraction_coef_flag,
+                                     parameters.generator);
         OrientedGraphs graphs;
         InputEdgeList  input_edges;
         OutputEdgeList output_edges;

+ 14 - 37
src/tests/boost_graph/graph_partitioning.hpp

@@ -28,6 +28,7 @@
 #define __TESTS_BOOST_GRAPH_GRAPH_PARTITIONING_HPP 1
 
 #include <tests/boost_graph/graph_defs.hpp>
+#include <tests/boost_graph/graph_generator.hpp>
 #include <tests/boost_graph/partitioning/graph_build.hpp>
 #include <tests/boost_graph/partitioning/gggp.hpp>
 
@@ -35,12 +36,13 @@
 
 namespace paradevs { namespace tests { namespace boost_graph {
 
+//template < class GraphGenerator >
 class PartitioningGraphBuilder
 {
 public:
-    PartitioningGraphBuilder(int cn, std::string pmn, int cc, bool ccf) :
-        cluster_number(cn), partitioning_method_name(pmn),
-        contraction_coef(cc), contraction_coef_flag(ccf)
+    PartitioningGraphBuilder(int cn, std::string pmn, int cc, bool ccf, GraphGenerator* g) :
+        cluster_number(cn),/*ajout d'un paramètre nbr_tirage,*/ partitioning_method_name(pmn),
+        contraction_coef(cc), contraction_coef_flag(ccf), generator(g)
     { }
 
     void build(OrientedGraphs& graphs,
@@ -51,19 +53,10 @@ public:
         UnorientedGraph* g = new UnorientedGraph();
         OrientedGraph go;
         UnorientedGraph graph_origin;
-
-        // internal examples
-        // {
-        //     build_graph(*g, go);
-        //     boost::copy_graph(*g, graph_origin);
-        // }
-
-        // corsen examples
-        {
-            build_corsen_graph(go);
-            make_unoriented_graph(go, *g);
-            boost::copy_graph(*g, graph_origin);
-        }
+        
+        generator->generate(go);
+        make_unoriented_graph(go, *g);
+        boost::copy_graph(*g, graph_origin);        
 
         Edges edge_partie;
         Connections connections;
@@ -73,16 +66,16 @@ public:
         if (contraction_coef_flag) {
             graphs = Multiniveau(num_vertices(*g) / contraction_coef,
                                  g, &graph_origin, &go,
-                                 cluster_number, "HEM",
+                                 cluster_number,25, "HEM",
                                  partitioning_method_name,
-                                 "cut_norm", "norm", edge_partie ,
+                                 "cut", "ratio", edge_partie ,
                                  output_edges, input_edges,
                                  parent_connections);
         } else {
             graphs = Multiniveau(contraction_coef, g, &graph_origin, &go,
-                                 cluster_number, "HEM",
+                                 cluster_number,25, "HEM",
                                  partitioning_method_name,
-                                 "cut_norm", "norm", edge_partie ,
+                                 "cut", "ratio", edge_partie ,
                                  output_edges, input_edges,
                                  parent_connections);
         }
@@ -147,23 +140,7 @@ private:
     std::string partitioning_method_name;
     int contraction_coef;
     bool contraction_coef_flag;
-};
-
-class CorsenFlatGraphBuilder
-{
-public:
-    CorsenFlatGraphBuilder()
-    { }
-
-    void build(OrientedGraphs& graphs, InputEdgeList& /* input_edges */,
-               OutputEdgeList& /* output_edges */,
-               Connections& /* parent_connections */)
-    {
-        OrientedGraph graph;
-
-        build_corsen_graph(graph);
-        graphs.push_back(graph);
-    }
+    GraphGenerator* generator;
 };
 
 } } } // namespace paradevs tests boost_graph

+ 1 - 1
src/tests/boost_graph/partitioning/CMakeLists.txt

@@ -15,7 +15,7 @@ SET(PARTITIONING_CPP utils.cpp gggp.cpp graph_build.cpp)
 
 ADD_LIBRARY(partitioning SHARED ${PARTITIONING_HPP};${PARTITIONING_CPP})
 
-TARGET_LINK_LIBRARIES(partitioning corsen
+TARGET_LINK_LIBRARIES(partitioning
   ${Boost_LIBRARIES}
   ${GLIBMM_LIBRARIES}
   ${LIBXML_LIBRARIES}

+ 188 - 233
src/tests/boost_graph/partitioning/gggp.cpp

@@ -28,6 +28,7 @@
 
 #include <algorithm>
 #include <iostream>
+#include <fstream>
 
 namespace paradevs { namespace tests { namespace boost_graph {
 
@@ -38,13 +39,13 @@ extern OrientedGraph::vertex_iterator vertexIto, vertexEndo;
 extern OrientedGraph::adjacency_iterator neighbourIto, neighbourEndo;
 
 void ggp(UnorientedGraph *g, Entiers *sommetsSource,
-               Entiers *sommetsDestination, EntiersEntiers &Partition)
+               Entiers *sommetsDestination, EntiersEntiers &Partition, int rand)
 {
     //std::cout<<""<<std::endl;
-    int val;
+    //int val;
     Entiers sommets_adj;
     if(sommetsSource->size()==1){
-        val=0;
+        //val=0;
         //std::cout<<"Entré dans le debug ! "<<std::endl;
         Entiers tailles;
         for(uint i=0;i<Partition.size();i++){
@@ -54,13 +55,13 @@ void ggp(UnorientedGraph *g, Entiers *sommetsSource,
         for(uint i=0; i<Partition.size();i++){
             if(Partition.at(i)->size()==tmp)
             {
-                ggp(g,Partition[i],sommetsDestination,Partition);
+                ggp(g,Partition[i],sommetsDestination,Partition,rand_fini(0,Partition.at(i)->size()));
                 return;
             }
         }
     }
-    else
-        val=rand_fini(0,sommetsSource->size()-1);//Tirage aléatoire de l'indice du premier sommet entre 0 et taille du tableau -1
+   // else
+       // val=rand_fini(0,sommetsSource->size()-1);//Tirage aléatoire de l'indice du premier sommet entre 0 et taille du tableau -1
         //std::cout<<"val : "<<sommetsSource->at(val)<<std::endl;
     double poids_max=0;
     for(uint i=0;i<sommetsSource->size();i++){
@@ -68,9 +69,9 @@ void ggp(UnorientedGraph *g, Entiers *sommetsSource,
     }
     poids_max/=2.;
 
-    double poids=(*g)[sommetsSource->at(val)]._weight;
-    sommetsDestination->push_back(sommetsSource->at(val));
-    sommetsSource->erase(sommetsSource->begin() + val);
+    double poids=(*g)[sommetsSource->at(rand)]._weight;
+    sommetsDestination->push_back(sommetsSource->at(rand));
+    sommetsSource->erase(sommetsSource->begin() + rand);
     int cpt = 0;
 
    // std::cout<<"taille sommetsSource avant le while : "<<sommetsSource->size()<<std::endl;
@@ -80,7 +81,7 @@ void ggp(UnorientedGraph *g, Entiers *sommetsSource,
         if(cpt<sommetsDestination->size() )
             adjacence_ggp(sommetsDestination->at(cpt),sommets_adj,g);
         else{
-            val=rand_fini(0,sommetsSource->size()-1);
+            int val=rand_fini(0,sommetsSource->size()-1);
             sommetsDestination->push_back(sommetsSource->at(val));
             sommetsSource->erase(sommetsSource->begin() + val);
             adjacence_ggp(sommetsDestination->at(cpt),sommets_adj,g);
@@ -142,72 +143,37 @@ void ggp(UnorientedGraph *g, Entiers *sommetsSource,
 
     }
 
-    for (uint i=0; i<sommetsSource->size();i++)
+    /*for (uint i=0; i<sommetsSource->size();i++)
     {
         for (uint j=0; j<sommetsDestination->size();j++)
         {
             remove_edge(sommetsSource->at(i),sommetsDestination->at(j),*g);
         }
-    }
+    }*/
     sort(sommetsDestination->begin(), sommetsDestination->end());
 }
 
+
 void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
-             const std::string &nom)
+             const std::string &nom_cut, int nbr_tirage, const std::string &nom_strat)
 {
-    if (nom =="gggp"){
-
-        for(int i = 0; i<floor(log(nbr_parties)/log(2)); i++)
-        {
-            for(int j = 0; j< pow(2,i);j++)
-            {
-                Entiers *Q = new Entiers();
-                gggp(g,part[j],Q,part);
-                part.push_back(Q);
-            }
-        }
-    }
-
-    else if (nom =="ggp"){
- for(int i = 0; i<floor(log(nbr_parties)/log(2)); i++)
-        {
-            //std::cout<<"Et un tours de plus !!!! "<<std::endl;
-            for(int j = 0; j< pow(2,i);j++)
-            {
-                Entiers *Q = new Entiers();
-                ggp(g,part[j],Q,part);
-                part.push_back(Q);
-            }
-
-        }
-    }
-
-    else {
-        //std::cout<<"je jsuis dans gggp_pond"<<std::endl;
-
-        for(int i = 0; i<floor(log(nbr_parties)/log(2)); i++)
+	for(int i = 0; i<floor(log(nbr_parties)/log(2)); i++)
+    {
+		for(int j = 0; j< pow(2,i);j++)
         {
-            //std::cout<<"Et un tours de plus !!!! "<<std::endl;
-            for(int j = 0; j< pow(2,i);j++)
-            {
-                Entiers *Q = new Entiers();
-                gggp_pond(g,part.at(j),Q,part);
-                //std::clog<<"sortie du gggp_pond"<<std::endl;
-                part.push_back(Q);
-            }
-            //std::cout<<"\n"<<std::endl;
-
+			//std::cout<<"Dans iter2l"<<std::endl;
+			Optimisation_method_neighbour(g, part, j, nbr_tirage, nom_cut, nom_strat);
         }
     }
 }
 
 void bissectionRec(UnorientedGraph *g, EntiersEntiers &Partition,
-                   int nbr_parties, const std::string &nom)
+                   int nbr_parties, const std::string &nom_cut, int nbr_tirage, const std::string &nom_strat)
 {
     if((nbr_parties&(nbr_parties-1))==0)
     {
         //std::cout<<"C'est de la forme 2l : "<<nbr_parties<<std::endl;
-        Iter_2l(Partition,nbr_parties,g,nom);
+        Iter_2l(Partition,nbr_parties,g,nom_cut,nbr_tirage,nom_strat);
     }
     else
     {
@@ -218,7 +184,7 @@ void bissectionRec(UnorientedGraph *g, EntiersEntiers &Partition,
         while(pow(2,puissance_2)<nbr_parties)
             puissance_2++;
 
-        Iter_2l(Partition,pow(2,puissance_2-1),g,nom);
+        Iter_2l(Partition,pow(2,puissance_2-1),g,nom_cut,nbr_tirage,nom_strat);
 
         for(unsigned int i = 0; i< Partition.size() -1 ; i++)
         {
@@ -231,115 +197,16 @@ void bissectionRec(UnorientedGraph *g, EntiersEntiers &Partition,
 
         for(int j = 0; j<nbr_parties-pow(2,puissance_2-1);j++)
         {
-            Entiers *Q = new Entiers();
-            if(nom=="gggp")
-                gggp(g,Partition.at(j),Q,Partition);
-            else if (nom == "ggp")
-                ggp(g,Partition.at(j),Q,Partition);
-            else
-                gggp_pond(g,Partition.at(j),Q,Partition);
-            Partition.push_back(Q);
+			Optimisation_method_neighbour(g,Partition,j,nbr_tirage, nom_cut, nom_strat);
         }
     }
 }
 
-
-
-void gggp(UnorientedGraph *g, Entiers *sommetsSource,
-          Entiers *sommetsDestination, EntiersEntiers &Partition)
-{
-    int val;
-    Entiers sommets_adj;
-
-    if (sommetsSource->size() - 1 == 0) {
-        Entiers tailles;
-
-        val = 0;
-        for (uint i = 0;i < Partition.size(); i++) {
-            tailles.push_back(Partition.at(i)->size());
-        }
-
-        uint tmp = *max_element(tailles.begin(), tailles.end());
-
-        for (uint i = 0; i < Partition.size(); i++) {
-            if (Partition.at(i)->size() == tmp) {
-                gggp(g, Partition.at(i), sommetsDestination, Partition);
-            }
-            break;
-        }
-    } else {
-
-        // Tirage aléatoire de l'indice du premier sommet entre 0 et
-        // taille du tableau -1
-        val = rand_fini(0, sommetsSource->size() - 1);
-    }
-
-    float poids_max=sommetsSource->size()/2.;
-    float poids=1;
-    Entiers sommets_cut;
-
-    //clog<<"Etape 1 : "<<std::endl;
-    sommetsDestination->push_back(sommetsSource->at(val));
-    sommetsSource->erase(sommetsSource->begin() + val);
-
-    if (sommetsSource->size() < 2) {
-        return;
-    }
-
-    while (poids < poids_max) {
-//		for(uint i =0; i< sommetsDestination.size();i++){
-//			std::cout<<sommetsDestination.at(i)<<std::endl;
-//		}
-        Liste_Voisin(*sommetsDestination, sommets_adj, *g);
-        if (sommets_adj.size() == 0) {
-            for (uint i=0; i<sommetsSource->size();i++)
-            {
-                for (uint j=0; j<sommetsDestination->size();j++)
-                {
-                    remove_edge(sommetsSource->at(i),sommetsDestination->at(j),*g);
-                }
-            }
-            sort(sommetsDestination->begin(), sommetsDestination->end());
-            return;
-        } else {
-            /*clog<<"Liste voisin est : "<<std::endl;
-              for(int i=0;i<sommets_adj.size();i++)
-              {
-              std::cout<<sommets_adj[i]<<std::endl;
-              }*/
-            std::sort(sommets_adj.begin(), sommets_adj.end());
-            for (uint i = 0; i < sommets_adj.size(); i++) {
-                sommets_cut.push_back(Cout_coupe(*sommetsDestination,
-                                                 sommets_adj[i], *g));
-            }
-
-            int tmp = recherche_val(sommets_cut,
-                                    *min_element(sommets_cut.begin(),
-                                                 sommets_cut.end()));
-            sommetsDestination->push_back(sommets_adj[tmp]);
-            suprim_val(*sommetsSource, sommets_adj[tmp]);
-            suprim_val(sommets_adj, sommets_adj[tmp]);
-
-            sommets_cut.clear();
-            poids++;
-        }
-    }
-
-    for (uint i = 0; i < sommetsSource->size(); i++) {
-        for (uint j = 0; j < sommetsDestination->size(); j++) {
-            remove_edge(sommetsSource->at(i), sommetsDestination->at(j), *g);
-        }
-    }
-    sort(sommetsDestination->begin(), sommetsDestination->end());
-}
-
 void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource,
-               Entiers *sommetsDestination, EntiersEntiers &Partition)
+               Entiers *sommetsDestination, EntiersEntiers &Partition, int rand)
 {
-    int val;
     Entiers sommets_adj;
     if(sommetsSource->size()==1){
-        val=0;
         Entiers tailles;
         for(uint i=0;i<Partition.size();i++){
             tailles.push_back(Partition.at(i)->size());
@@ -348,23 +215,22 @@ void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource,
         for(uint i=0; i<Partition.size();i++){
             if(Partition.at(i)->size()==tmp)
             {
-                gggp_pond(g,Partition[i],sommetsDestination,Partition);
+                gggp_pond(g,Partition[i],sommetsDestination,Partition,rand_fini(0,Partition.at(i)->size()));
                 return;
             }
         }
     }
-    else
-        val=rand_fini(0,sommetsSource->size()-1);
+
     double poids_max=0;
     for(uint i=0;i<sommetsSource->size();i++){
         poids_max+=(*g)[sommetsSource->at(i)]._weight;
     }
     poids_max/=2.;
-    double poids=(*g)[sommetsSource->at(val)]._weight;
+    double poids=(*g)[sommetsSource->at(rand)]._weight;
     std::vector<float> sommets_cut;
-    float cut = Degree(*g,sommetsSource->at(val));
-    sommetsDestination->push_back(sommetsSource->at(val));
-    sommetsSource->erase(sommetsSource->begin() + val);
+    float cut = Degree(*g,sommetsSource->at(rand));
+    sommetsDestination->push_back(sommetsSource->at(rand));
+    sommetsSource->erase(sommetsSource->begin() + rand);
 
     while(poids<poids_max && sommetsSource->size()>1)
     {
@@ -400,13 +266,13 @@ void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource,
         }
     }
 
-    for (uint i=0; i<sommetsSource->size();i++)
+    /*for (uint i=0; i<sommetsSource->size();i++)
     {
         for (uint j=0; j<sommetsDestination->size();j++)
         {
             remove_edge(sommetsSource->at(i),sommetsDestination->at(j),*g);
         }
-    }
+    }*/
     sort(sommetsDestination->begin(), sommetsDestination->end());
 
 }
@@ -742,6 +608,7 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
                            UnorientedGraph *graph_origin,
                            OrientedGraph *go,
                            int nbr_parties,
+                           int nbr_tirage,
                            std::string contraction,
                            std::string type_methode,
                            std::string choix_affinage,
@@ -772,9 +639,15 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
     	else
     		stop = contraction_Random_Maching(baseg.at(cpt),baseg,liste_corr,niveau_contraction,val_cpt);
         cpt++;
-        // std::cout<<"passage"<<std::endl;
     }
-
+    
+    for(int i = 0; i<num_vertices(*baseg.at(baseg.size() - 1)); i++){
+		part->push_back(i);
+	}
+	Partition.push_back(part);
+	
+	UnorientedGraph copy_graph;
+	boost::copy_graph(*baseg.at(baseg.size()-1),copy_graph);
     // std::cout<<"Graphe contracté : "<<std::endl;
     // for (uint i = 0; i< baseg.size(); i++) {
     //     tie(vertexIt, vertexEnd) = vertices(*baseg[i]);
@@ -790,54 +663,12 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
     //     }
     //     std::cout << std::endl;
     // }
-    UnorientedGraph *gtmp = new UnorientedGraph();
-    *gtmp = *baseg.at(baseg.size() - 1);
-    // std::cout<<"Partitionnement "<<std::endl;
-    if(type_methode == "gggp_pond" || type_methode == "gggp" || type_methode == "ggp"){
-		for(uint i = 0;i < num_vertices(*baseg.at(baseg.size() - 1)); i++)
-		{
-			part->push_back(i);
-		}
-		Partition.push_back(part);
-		bissectionRec(baseg.at(baseg.size()-1),Partition,nbr_parties,type_methode);
-		double cut_norm = Cut_cluster(Partition,*gtmp,"norm");
-		// std::cout<<"Cout de coupe normalisé initial : "<<cut_norm<<std::
-                    // endl;
-		int cpt_part = 0;
-		while (cpt_part!=3){
-			EntiersEntiers new_Partition;
-			Entiers *new_part = new Entiers();
-			for(uint i = 0;i < num_vertices(*baseg.at(baseg.size() - 1)); i++)
-			{
-				new_part->push_back(i);
-			}
-			new_Partition.push_back(new_part);
-			bissectionRec(baseg.at(baseg.size()-1),new_Partition,nbr_parties,type_methode);
-			double new_cut_norm = Cut_cluster(new_Partition,*gtmp,"norm");
-			// std::cout<<"Nouveau cout de coupe normalisé : "<<new_cut_norm<<std::endl;
-
-			if(new_cut_norm<cut_norm){
-				// std::cout<<"Changement !!!"<<std::endl;
-				for(EntiersEntiers::iterator it = Partition.begin(); it != Partition.end(); it++)
-				{
-					delete *it;
-					*it = NULL;
-				}
-				Partition = new_Partition;
-				cut_norm = new_cut_norm;
-			}
-			else{
-				for(EntiersEntiers::iterator it = new_Partition.begin(); it != new_Partition.end(); it++)
-				{
-					delete *it;
-					*it = NULL;
-				}
-			}
-			cpt_part++;
-		}
-		// std::cout<<std::endl;
-		// std::cout<<"Cout de coupe normalisé conservé : "<<cut_norm<<std::endl;
-		delete gtmp;
+    
+    if(type_methode == "gggp" || type_methode == "ggp"){
+		bissectionRec(baseg.at(baseg.size()-1),Partition,nbr_parties,type_cut,nbr_tirage,type_methode);
+		double best_cut = Cut_cluster(Partition,copy_graph,type_cut);
+		std::cout<<"Meilleur coût de coupe : "<<best_cut<<std::endl;
+		std::cout<<std::endl;
     }
     else
     	Partition = Random_partitioning(baseg.at(baseg.size()-1),nbr_parties);
@@ -861,8 +692,8 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
     		projection(Partition,lit);
     		// std::cout<<std::endl;
     		double cut = Cut_cluster(Partition,*baseg.at(baseg.size()-2-y),type_cut);
-    		// std::cout<<"Cout de coupe avant affinage : "<<cut<<std::endl;
-    		// std::cout<<std::endl;
+    		std::cout<<"Cout de coupe avant affinage : "<<cut<<std::endl;
+    		std::cout<<std::endl;
     		// std::cout<<"Affinage "<<std::endl;
     		if(choix_affinage=="charge")
     			Affinage_equilibrage_charge(baseg.at(baseg.size()-2-y),Partition);
@@ -878,8 +709,7 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
     		if(nbr_parties != num_vertices(*g)){
     			// std::cout<<"Affinage "<<std::endl;
         		double cut = Cut_cluster(Partition,*graph_origin,type_cut);
-        		// std::cout<<"Cout de coupe avant affinage : "<<cut<<std::
-                            // endl;
+        		std::cout<<"Cout de coupe avant affinage : "<<cut<<std::endl;
     			if(choix_affinage=="charge")
     				Affinage_equilibrage_charge(graph_origin,Partition);
     			else{
@@ -895,19 +725,48 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
 
     OrientedGraphs Graphes = Graph_Partition(Partition, go, graph_origin, outputedgelist,
                                              inputedgelist, connections);
+	std::vector<std::string> color;
+    color.push_back("[color=blue2, fontcolor=blue2];");
+    color.push_back("[color=red, fontcolor=red];");
+    color.push_back("[color=green, fontcolor=green];");
+    color.push_back("[color=yellow, fontcolor=yellow2];");
+    color.push_back("[color=saddlebrown, fontcolor=saddlebrown];");
+    color.push_back("[color=turquoise, fontcolor=turquoise];");
+    color.push_back("[color=orange, fontcolor=orange];");
+    color.push_back("[color=olivedrab, fontcolor=olivedrab];");
+    color.push_back("[color=indigo, fontcolor=indigo];");
+    color.push_back("[color=gold, fontcolor=gold];");
+    color.push_back("[color=slateblue2, fontcolor=slateblue2];");
+    color.push_back("[color=dimgrey, fontcolor=dimgrey];");
+    color.push_back("[color=cyan, fontcolor=cyan];");
+    color.push_back("[color=purple1, fontcolor=purpule1];");
+    color.push_back("[color=crimson, fontcolor=crimson];");
+    color.push_back("[color=black, fontcolor=black];");
+    
+   /*std::ofstream fichier2 ("../../sortie_graphe/graph_partition_38_4.txt", std::ios::out);
+   fichier2<<"digraph G {"<<std::endl;   
+   tie(vertexIto, vertexEndo) = vertices(*go);
+   for (; vertexIto != vertexEndo; ++vertexIto) {
+	fichier2<<(*go)[*vertexIto]._index<<"-> {";
+    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
+    			*go);
+    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
+    		fichier2<<(*go)[*neighbourIto]._index<<";";
+    	}
+    	fichier2<<"}"<<std::endl;
+    }
+    
+    for(uint k=0; k<Partition.size(); k++){
+		for(uint j=0; j<Partition.at(k)->size(); j++)
+		{
+     		fichier2<<Partition.at(k)->at(j)<<color.at(k)<<std::endl;
+		}
+    }   
+    
+	fichier2<<"}";	
+	fichier2.close();*/
 
-    // std::cout<<std::endl;
-    // std::cout<<"Résultat de la partition "<<std::endl;
-    // for(uint k=0; k<Partition.size(); k++)
-    // {
-    // 	for(uint j=0; j<Partition.at(k)->size(); j++)
-    // 	{
-    // 		std::cout<<Partition.at(k)->at(j)<<" ";
-    // 	}
-    // 	std::cout<<"\n"<<std::endl;
-    // }
-
-	double cut = Cut_cluster(Partition,*graph_origin,"cut");
+	//double cut = Cut_cluster(Partition,*graph_origin,"cut");
 	// std::cout<<"Cout de coupe engendré par le partitionnement: "<<cut<<std::endl;
 
 
@@ -936,4 +795,100 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
     return Graphes;
 }
 
+void Optimisation_method_neighbour(UnorientedGraph *g, EntiersEntiers &Partition, int index_partition, int nbr_tirage, const std::string &name_cut, const std::string &name_strat){
+	/*Initialisation des parametres*/
+	//UnorientedGraph *copy_g_ref = new UnorientedGraph();
+	Entiers *part2_cons = new Entiers();
+	Entiers *part_cour_cons = new Entiers();
+	Entiers Random_list_vertices;
+	double cut=1000000000.;
+	//boost::copy_graph(*g,*copy_g_ref);
+
+	for (int i=0 ; i<Partition.at(index_partition)->size() ; i++)
+		Random_list_vertices.push_back(i);
+	for (int j=0 ; j<Partition.at(index_partition)->size()-1 ; j++) {
+		int rand_pos = rand()%(Partition.at(index_partition)->size()-j)+j;
+		int tmp      = Random_list_vertices[j];
+		Random_list_vertices[j] = Random_list_vertices[rand_pos];
+		Random_list_vertices[rand_pos] = tmp;
+	}
+	
+	if(Partition.at(index_partition)->size()< nbr_tirage)
+		nbr_tirage = Partition.at(index_partition)->size();
+		
+	/*Boucle de conservation de la meilleure bissection*/
+	for(int k = 0; k<nbr_tirage; k++){
+		//UnorientedGraph *copy_g =  new UnorientedGraph();
+		Entiers *part2 = new Entiers();
+		Entiers *tmp_part = new Entiers();
+		double new_cut;
+		//boost::copy_graph(*g,*copy_g);
+
+		/*Recopie de la partie faisant l'objet de la bissection */
+		for(int t=0; t<Partition.at(index_partition)->size();t++){
+			tmp_part->push_back(Partition.at(index_partition)->at(t));
+		}
+		
+		/*std::cout<<"Ensembles verification  !!! "<<std::endl;
+		std::cout<<"Ensemble 1 : ";
+		for(uint i = 0; i < tmp_part->size(); i++){
+			std::cout<<tmp_part->at(i)<<" ";
+		}
+		std::cout<<std::endl;
+		std::cout<<"Ensemble 2 : ";
+		for(uint j = 0; j < part2->size(); j++){
+			std::cout<<part2->at(j)<<" ";
+		}
+		std::cout<<std::endl;*/
+		
+		//gggp_pond(copy_g,tmp_part,part2,Partition);
+
+		if(name_strat == "gggp"){
+			gggp_pond(g,tmp_part,part2,Partition,Random_list_vertices.at(k));
+		} else if(name_strat == "ggp"){
+			ggp(g,tmp_part,part2,Partition,Random_list_vertices.at(k));
+		} else {
+			std::cout<<"Nom de stratégie de partitionnement non valide ! "<<std::endl;
+		}
+		
+		/*std::cout<<"Ensemble 1 : ";
+		for(uint i = 0; i < tmp_part->size(); i++){
+			std::cout<<tmp_part->at(i)<<" ";
+		}
+		std::cout<<std::endl;
+		std::cout<<"Ensemble 2 : ";
+		for(uint j = 0; j < part2->size(); j++){
+			std::cout<<part2->at(j)<<" ";
+		}
+		std::cout<<std::endl;
+		std::cout<<std::endl;*/
+		new_cut = Best_Cut_cluster(Partition, tmp_part, part2, index_partition,*g,name_cut);
+		//std::cout<<"Cout de coupe initial : "<<cut<<" "<<"Résutlat : "<<new_cut<<std::endl;
+		//std::cout<<std::endl;
+		if(new_cut<cut){ /*conservation de l'information en cas d'amélioration de la contrainte*/
+			cut = new_cut;
+			//copy_g_ref = copy_g;
+			part2_cons = part2;
+			part_cour_cons = tmp_part;
+		}
+		else{
+			//delete copy_g;
+			delete tmp_part;
+			delete part2;
+		}	
+	}
+	
+	for (uint i=0; i<part_cour_cons->size();i++)
+    {
+        for (uint j=0; j<part2_cons->size();j++)
+        {
+            remove_edge(part_cour_cons->at(i),part2_cons->at(j),*g);
+        }
+    }
+	/*Modification des informations*/
+	Partition.at(index_partition)=part_cour_cons;
+	Partition.push_back(part2_cons);
+	//g=copy_g_ref;
+}
+
 } } } // namespace paradevs tests boost_graph

+ 8 - 8
src/tests/boost_graph/partitioning/gggp.hpp

@@ -28,23 +28,21 @@
 #define TESTS_BOOST_GRAPH_PARTITIONING_GGGP_H 1
 
 #include <tests/boost_graph/partitioning/utils.hpp>
+#include <boost/graph/copy.hpp>
 
 namespace paradevs { namespace tests { namespace boost_graph {
 
 void ggp(UnorientedGraph *g, Entiers *sommetsSource,
-         Entiers *sommetsDestination, EntiersEntiers &Partition);
-
-void gggp(UnorientedGraph *g, Entiers *sommetsSource,
-          Entiers *sommetsDestination, EntiersEntiers &Partition);
+         Entiers *sommetsDestination, EntiersEntiers &Partition,int rand);
 
 void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource,
-               Entiers *sommetsDestination, EntiersEntiers &Partition);
+               Entiers *sommetsDestination, EntiersEntiers &Partition, int rand);
 
 void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
-             const std::string &nom);
+             const std::string &nom_cut, int nbr_tirage, const std::string &nom_strat);
 
 void bissectionRec(UnorientedGraph *g, EntiersEntiers &Partition,
-                   int nbr_parties, const std::string &nom);
+                   int nbr_parties, const std::string &nom_cut, int nbr_tirage, const std::string &nom_strat);
 
 void Pseudo_random_partitioning(UnorientedGraph *g, EntiersEntiers &Partition,
                                 uint nbr_parties);
@@ -53,7 +51,7 @@ EntiersEntiers Random_partitioning(UnorientedGraph *g,
                                 uint nbr_parties);
 
 OrientedGraphs Multiniveau(uint niveau_contraction, UnorientedGraph *g, UnorientedGraph *graph_origin,
-                           OrientedGraph *go, int nbr_parties,
+                           OrientedGraph *go, int nbr_parties, int nbr_tirage,
                            std::string contraction,
                            std::string type_methode,
                            std::string choix_affinage,
@@ -62,6 +60,8 @@ OrientedGraphs Multiniveau(uint niveau_contraction, UnorientedGraph *g, Unorient
                            OutputEdgeList &outputedgeslist,
                            InputEdgeList &inputedgelist,
                            Connections &connections);
+void Optimisation_method_neighbour(UnorientedGraph *g, EntiersEntiers &Partition, int index_partition, int nbr_tirage, const std::string &name_cut, const std::string &name_strat);
+
 
 } } } // namespace paradevs tests boost_graph
 

+ 544 - 323
src/tests/boost_graph/partitioning/graph_build.cpp

@@ -25,335 +25,206 @@
  */
 
 #include <tests/boost_graph/partitioning/graph_build.hpp>
+#include <iostream>
 
-#include <tests/corsen/lib/Corsen.hpp>
+//#include <tests/corsen/lib/Corsen.hpp>
 
 namespace paradevs { namespace tests { namespace boost_graph {
 
-void build_graph(UnorientedGraph& ug, OrientedGraph& og)
+void build_graph(OrientedGraph& og, unsigned int edge_number)
 {
 
-    /*
-     * construction graphe Oriente
-     */
-    vertex_to v0 = boost::add_vertex(og);
-    vertex_to v1 = boost::add_vertex(og);
-    vertex_to v2 = boost::add_vertex(og);
-    vertex_to v3 = boost::add_vertex(og);
-    vertex_to v4 = boost::add_vertex(og);
-    vertex_to v5 = boost::add_vertex(og);
-    vertex_to v6 = boost::add_vertex(og);
-    vertex_to v7 = boost::add_vertex(og);
-    vertex_to v8 = boost::add_vertex(og);
-    vertex_to v9 = boost::add_vertex(og);
-    vertex_to v10 = boost::add_vertex(og);
-    vertex_to v11 = boost::add_vertex(og);
-    vertex_to v12 = boost::add_vertex(og);
-    vertex_to v13 = boost::add_vertex(og);
-    vertex_to v14 = boost::add_vertex(og);
-    vertex_to v15 = boost::add_vertex(og);
-    vertex_to v16 = boost::add_vertex(og);
-    vertex_to v17 = boost::add_vertex(og);
-    vertex_to v18 = boost::add_vertex(og);
-    vertex_to v19 = boost::add_vertex(og);
-    vertex_to v20 = boost::add_vertex(og);
-    vertex_to v21 = boost::add_vertex(og);
-    vertex_to v22 = boost::add_vertex(og);
-    vertex_to v23 = boost::add_vertex(og);
-    vertex_to v24 = boost::add_vertex(og);
-    vertex_to v25 = boost::add_vertex(og);
-    vertex_to v26 = boost::add_vertex(og);
-    vertex_to v27 = boost::add_vertex(og);
-    vertex_to v28 = boost::add_vertex(og);
-    vertex_to v29 = boost::add_vertex(og);
-    vertex_to v30 = boost::add_vertex(og);
-    vertex_to v31 = boost::add_vertex(og);
-    vertex_to v32 = boost::add_vertex(og);
-    vertex_to v33 = boost::add_vertex(og);
-    vertex_to v34 = boost::add_vertex(og);
-    vertex_to v35 = boost::add_vertex(og);
-    vertex_to v36 = boost::add_vertex(og);
-    vertex_to v37 = boost::add_vertex(og);
-
-
-
-    add_edge(v1, v0, EdgeProperties(1.), og);
-    add_edge(v2, v0, EdgeProperties(1.), og);
-    add_edge(v3, v0, EdgeProperties(1.), og);
-    add_edge(v1, v2, EdgeProperties(1.), og);
-    add_edge(v4, v1, EdgeProperties(1.), og);
-    add_edge(v5, v1, EdgeProperties(1.), og);
-    add_edge(v6, v1, EdgeProperties(1.), og);
-    add_edge(v6, v2, EdgeProperties(1.), og);
-    add_edge(v2, v3, EdgeProperties(1.), og);
-    add_edge(v9, v3, EdgeProperties(1.), og);
-    add_edge(v10, v3, EdgeProperties(1.), og);
-    add_edge(v4, v5, EdgeProperties(1.), og);
-    add_edge(v5, v6, EdgeProperties(1.), og);
-    add_edge(v7, v4, EdgeProperties(1.), og);
-    add_edge(v8, v4, EdgeProperties(1.), og);
-    add_edge(v7, v8, EdgeProperties(1.), og);
-    add_edge(v9, v10, EdgeProperties(1.), og);
-    add_edge(v8, v11, EdgeProperties(1.), og);
-    add_edge(v11, v4, EdgeProperties(1.), og);
-    add_edge(v12, v13, EdgeProperties(1.), og);
-    add_edge(v12, v7, EdgeProperties(1.), og);
-    add_edge(v13, v7, EdgeProperties(1.), og);
-    add_edge(v14, v15, EdgeProperties(1.), og);
-    add_edge(v14, v12, EdgeProperties(1.), og);
-    add_edge(v15, v16, EdgeProperties(1.), og);
-    add_edge(v15, v12, EdgeProperties(1.), og);
-    add_edge(v16, v17, EdgeProperties(1.), og);
-    add_edge(v16, v12, EdgeProperties(1.), og);
-    add_edge(v17, v12, EdgeProperties(1.), og);
-    add_edge(v18, v19, EdgeProperties(1.), og);
-    add_edge(v18, v8, EdgeProperties(1.), og);
-    add_edge(v19, v20, EdgeProperties(1.), og);
-    add_edge(v19, v8, EdgeProperties(1.), og);
-    add_edge(v20, v8, EdgeProperties(1.), og);
-    add_edge(v21, v22, EdgeProperties(1.), og);
-    add_edge(v21, v19, EdgeProperties(1.), og);
-    add_edge(v22, v23, EdgeProperties(1.), og);
-    add_edge(v22, v19, EdgeProperties(1.), og);
-    add_edge(v23, v19, EdgeProperties(1.), og);
-    add_edge(v24, v25, EdgeProperties(1.), og);
-    add_edge(v24, v6, EdgeProperties(1.), og);
-    add_edge(v25, v6, EdgeProperties(1.), og);
-    add_edge(v26, v11, EdgeProperties(1.), og);
-    add_edge(v26, v27, EdgeProperties(1.), og);
-    add_edge(v26, v24, EdgeProperties(1.), og);
-    add_edge(v27, v24, EdgeProperties(1.), og);
-    add_edge(v28, v25, EdgeProperties(1.), og);
-    add_edge(v29, v27, EdgeProperties(1.), og);
-    add_edge(v29, v28, EdgeProperties(1.), og);
-    add_edge(v30, v27, EdgeProperties(1.), og);
-    add_edge(v30, v28, EdgeProperties(1.), og);
-    add_edge(v31, v32, EdgeProperties(1.), og);
-    add_edge(v31, v10, EdgeProperties(1.), og);
-    add_edge(v32, v33, EdgeProperties(1.), og);
-    add_edge(v32, v10, EdgeProperties(1.), og);
-    add_edge(v33, v10, EdgeProperties(1.), og);
-    add_edge(v34, v31, EdgeProperties(1.), og);
-    add_edge(v34, v35, EdgeProperties(1.), og);
-    add_edge(v35, v31, EdgeProperties(1.), og);
-    add_edge(v35, v32, EdgeProperties(1.), og);
-    add_edge(v36, v32, EdgeProperties(1.), og);
-    add_edge(v36, v37, EdgeProperties(1.), og);
-    add_edge(v36, v33, EdgeProperties(1.), og);
-    add_edge(v37, v33, EdgeProperties(1.), og);
-
-
-    /*og[v6] = VertexProperties(6, 1.5, NORMAL_PIXEL);
-    og[v8] = VertexProperties(8, 1., NORMAL_PIXEL);
-    og[v10] = VertexProperties(10, 1.5, NORMAL_PIXEL);
-    og[v0] = VertexProperties(0, 3, NORMAL_PIXEL);
-    og[v1] = VertexProperties(1, 2, NORMAL_PIXEL);
-    og[v2] = VertexProperties(2, 2, NORMAL_PIXEL);
-    og[v3] = VertexProperties(3, 2, NORMAL_PIXEL);
-    og[v4] = VertexProperties(4, 1.5, NORMAL_PIXEL);
-    og[v5] = VertexProperties(5, 1.5, NORMAL_PIXEL);
-    og[v7] = VertexProperties(7, 1., TOP_PIXEL);
-    og[v9] = VertexProperties(9, 1.5, TOP_PIXEL);*/
-
-    og[v6] = VertexProperties(6, 2.5, NORMAL_PIXEL);
-    og[v8] = VertexProperties(8, 2., NORMAL_PIXEL);
-    og[v10] = VertexProperties(10, 2.5, NORMAL_PIXEL);
-    og[v0] = VertexProperties(0, 4, NORMAL_PIXEL);
-    og[v1] = VertexProperties(1, 3, NORMAL_PIXEL);
-    og[v2] = VertexProperties(2, 3, NORMAL_PIXEL);
-    og[v3] = VertexProperties(3, 3, NORMAL_PIXEL);
-    og[v4] = VertexProperties(4, 2.5, NORMAL_PIXEL);
-    og[v5] = VertexProperties(5, 2.5, NORMAL_PIXEL);
-    og[v7] = VertexProperties(7, 2., NORMAL_PIXEL);
-    og[v9] = VertexProperties(9, 2.5, TOP_PIXEL);
-    og[v11] = VertexProperties(11, 2, NORMAL_PIXEL);
-    og[v12] = VertexProperties(12, 1.5, NORMAL_PIXEL);
-    og[v13] = VertexProperties(13, 1.5, NORMAL_PIXEL);
-    og[v14] = VertexProperties(14, 1, TOP_PIXEL);
-    og[v15] = VertexProperties(15, 1, NORMAL_PIXEL);
-    og[v16] = VertexProperties(16, 1, NORMAL_PIXEL);
-    og[v17] = VertexProperties(17, 1, NORMAL_PIXEL);
-    og[v18] = VertexProperties(18, 1.5, TOP_PIXEL);
-    og[v19] = VertexProperties(19, 1.5, NORMAL_PIXEL);
-    og[v20] = VertexProperties(20, 1.5, NORMAL_PIXEL);
-    og[v21] = VertexProperties(21, 1, TOP_PIXEL);
-    og[v22] = VertexProperties(22, 1, NORMAL_PIXEL);
-    og[v23] = VertexProperties(23, 1, NORMAL_PIXEL);
-    og[v24] = VertexProperties(24, 2, NORMAL_PIXEL);
-    og[v25] = VertexProperties(25, 2, NORMAL_PIXEL);
-    og[v26] = VertexProperties(26, 1.5, TOP_PIXEL);
-    og[v27] = VertexProperties(27, 1.5, NORMAL_PIXEL);
-    og[v28] = VertexProperties(28, 1.5, NORMAL_PIXEL);
-    og[v29] = VertexProperties(29, 1, TOP_PIXEL);
-    og[v30] = VertexProperties(30, 1, TOP_PIXEL);
-    og[v31] = VertexProperties(31, 2, NORMAL_PIXEL);
-    og[v32] = VertexProperties(32, 2, NORMAL_PIXEL);
-    og[v33] = VertexProperties(33, 2, NORMAL_PIXEL);
-    og[v34] = VertexProperties(34, 1.5, TOP_PIXEL);
-    og[v35] = VertexProperties(35, 1.5, NORMAL_PIXEL);
-    og[v36] = VertexProperties(36, 1.5, TOP_PIXEL);
-    og[v37] = VertexProperties(37, 1.5, NORMAL_PIXEL);
-
-
-    /*
-     * construction graphe Non Oriente
-     */
-
-    vertex_t v01 = boost::add_vertex(ug);
-    vertex_t v1r1 = boost::add_vertex(ug);
-    vertex_t v2r1 = boost::add_vertex(ug);
-    vertex_t v3r1 = boost::add_vertex(ug);
-    vertex_t v41 = boost::add_vertex(ug);
-    vertex_t v51 = boost::add_vertex(ug);
-    vertex_t v61 = boost::add_vertex(ug);
-    vertex_t v71 = boost::add_vertex(ug);
-    vertex_t v81 = boost::add_vertex(ug);
-    vertex_t v91 = boost::add_vertex(ug);
-    vertex_t v101 = boost::add_vertex(ug);
-    vertex_t v111 = boost::add_vertex(ug);
-    vertex_t v121 = boost::add_vertex(ug);
-    vertex_t v131 = boost::add_vertex(ug);
-    vertex_t v141 = boost::add_vertex(ug);
-    vertex_t v151 = boost::add_vertex(ug);
-    vertex_t v161 = boost::add_vertex(ug);
-    vertex_t v171 = boost::add_vertex(ug);
-    vertex_t v181 = boost::add_vertex(ug);
-    vertex_t v191 = boost::add_vertex(ug);
-    vertex_t v201 = boost::add_vertex(ug);
-    vertex_t v211 = boost::add_vertex(ug);
-    vertex_t v221 = boost::add_vertex(ug);
-    vertex_t v231 = boost::add_vertex(ug);
-    vertex_t v241 = boost::add_vertex(ug);
-    vertex_t v251 = boost::add_vertex(ug);
-    vertex_t v261 = boost::add_vertex(ug);
-    vertex_t v271 = boost::add_vertex(ug);
-    vertex_t v281 = boost::add_vertex(ug);
-    vertex_t v291 = boost::add_vertex(ug);
-    vertex_t v301 = boost::add_vertex(ug);
-    vertex_t v311 = boost::add_vertex(ug);
-    vertex_t v321 = boost::add_vertex(ug);
-    vertex_t v331 = boost::add_vertex(ug);
-    vertex_t v341 = boost::add_vertex(ug);
-    vertex_t v351 = boost::add_vertex(ug);
-    vertex_t v361 = boost::add_vertex(ug);
-    vertex_t v371 = boost::add_vertex(ug);
-
-    boost::add_edge(v01, v1r1, EdgeProperties(1.), ug);
-    boost::add_edge(v01, v2r1, EdgeProperties(1.), ug);
-    boost::add_edge(v01, v3r1, EdgeProperties(1.), ug);
-    boost::add_edge(v1r1, v2r1, EdgeProperties(1.), ug);
-    boost::add_edge(v1r1, v41, EdgeProperties(1.), ug);
-    boost::add_edge(v1r1, v51, EdgeProperties(1.), ug);
-    boost::add_edge(v1r1, v61, EdgeProperties(1.), ug);
-    boost::add_edge(v2r1, v61, EdgeProperties(1.), ug);
-    boost::add_edge(v2r1, v3r1, EdgeProperties(1.), ug);
-    boost::add_edge(v3r1, v91, EdgeProperties(1.), ug);
-    boost::add_edge(v3r1, v101, EdgeProperties(1.), ug);
-    boost::add_edge(v41, v51, EdgeProperties(1.), ug);
-    boost::add_edge(v51, v61, EdgeProperties(1.), ug);
-    boost::add_edge(v41, v71, EdgeProperties(1.), ug);
-    boost::add_edge(v41, v81, EdgeProperties(1.), ug);
-    boost::add_edge(v71, v81, EdgeProperties(1.), ug);
-    boost::add_edge(v91, v101, EdgeProperties(1.), ug);
-    boost::add_edge(v41, v111, EdgeProperties(1.), ug);
-    boost::add_edge(v71, v121, EdgeProperties(1.), ug);
-    boost::add_edge(v71, v131, EdgeProperties(1.), ug);
-    boost::add_edge(v121, v131, EdgeProperties(1.), ug);
-    boost::add_edge(v121, v141, EdgeProperties(1.), ug);
-    boost::add_edge(v121, v151, EdgeProperties(1.), ug);
-    boost::add_edge(v121, v161, EdgeProperties(1.), ug);
-    boost::add_edge(v121, v171, EdgeProperties(1.), ug);
-    boost::add_edge(v141, v151, EdgeProperties(1.), ug);
-    boost::add_edge(v151, v161, EdgeProperties(1.), ug);
-    boost::add_edge(v161, v171, EdgeProperties(1.), ug);
-    boost::add_edge(v81, v111, EdgeProperties(1.), ug);
-    boost::add_edge(v81, v181, EdgeProperties(1.), ug);
-    boost::add_edge(v81, v191, EdgeProperties(1.), ug);
-    boost::add_edge(v81, v201, EdgeProperties(1.), ug);
-    boost::add_edge(v181, v191, EdgeProperties(1.), ug);
-    boost::add_edge(v191, v201, EdgeProperties(1.), ug);
-    boost::add_edge(v191, v211, EdgeProperties(1.), ug);
-    boost::add_edge(v191, v221, EdgeProperties(1.), ug);
-    boost::add_edge(v191, v231, EdgeProperties(1.), ug);
-    boost::add_edge(v211, v221, EdgeProperties(1.), ug);
-    boost::add_edge(v221, v231, EdgeProperties(1.), ug);
-    boost::add_edge(v111, v261, EdgeProperties(1.), ug);
-    boost::add_edge(v61, v241, EdgeProperties(1.), ug);
-    boost::add_edge(v61, v251, EdgeProperties(1.), ug);
-    boost::add_edge(v241, v251, EdgeProperties(1.), ug);
-    boost::add_edge(v241, v261, EdgeProperties(1.), ug);
-    boost::add_edge(v241, v271, EdgeProperties(1.), ug);
-    boost::add_edge(v261, v271, EdgeProperties(1.), ug);
-    boost::add_edge(v251, v281, EdgeProperties(1.), ug);
-    boost::add_edge(v271, v291, EdgeProperties(1.), ug);
-    boost::add_edge(v271, v301, EdgeProperties(1.), ug);
-    boost::add_edge(v281, v291, EdgeProperties(1.), ug);
-    boost::add_edge(v281, v301, EdgeProperties(1.), ug);
-    boost::add_edge(v101, v311, EdgeProperties(1.), ug);
-    boost::add_edge(v101, v321, EdgeProperties(1.), ug);
-    boost::add_edge(v101, v331, EdgeProperties(1.), ug);
-    boost::add_edge(v311, v321, EdgeProperties(1.), ug);
-    boost::add_edge(v321, v331, EdgeProperties(1.), ug);
-    boost::add_edge(v311, v341, EdgeProperties(1.), ug);
-    boost::add_edge(v311, v351, EdgeProperties(1.), ug);
-    boost::add_edge(v321, v351, EdgeProperties(1.), ug);
-    boost::add_edge(v321, v361, EdgeProperties(1.), ug);
-    boost::add_edge(v331, v361, EdgeProperties(1.), ug);
-    boost::add_edge(v331, v371, EdgeProperties(1.), ug);
-    boost::add_edge(v341, v351, EdgeProperties(1.), ug);
-    boost::add_edge(v361, v371, EdgeProperties(1.), ug);
-
-    /*ug[v61] = VertexProperties(60, 1.5, NORMAL_PIXEL);
-    ug[v81] = VertexProperties(80, 1, NORMAL_PIXEL);
-    ug[v101] = VertexProperties(100, 1.5, NORMAL_PIXEL);
-    ug[v01] = VertexProperties(0, 3, NORMAL_PIXEL);
-    ug[v1r1] = VertexProperties(10, 2, NORMAL_PIXEL);
-    ug[v2r1] = VertexProperties(20, 2, NORMAL_PIXEL);
-    ug[v3r1] = VertexProperties(30, 2, NORMAL_PIXEL);
-    ug[v41] = VertexProperties(40, 1.5, NORMAL_PIXEL);
-    ug[v51] = VertexProperties(50, 1.5, NORMAL_PIXEL);
-    ug[v71] = VertexProperties(70, 1, TOP_PIXEL);
-    ug[v91] = VertexProperties(90, 1.5, TOP_PIXEL);*/
-
-    ug[v6] = VertexProperties(6, 2.5, NORMAL_PIXEL);
-    ug[v8] = VertexProperties(8, 2., NORMAL_PIXEL);
-    ug[v10] = VertexProperties(10, 2.5, NORMAL_PIXEL);
-    ug[v0] = VertexProperties(0, 4, NORMAL_PIXEL);
-    ug[v1] = VertexProperties(1, 3, NORMAL_PIXEL);
-    ug[v2] = VertexProperties(2, 3, NORMAL_PIXEL);
-    ug[v3] = VertexProperties(3, 3, NORMAL_PIXEL);
-    ug[v4] = VertexProperties(4, 2.5, NORMAL_PIXEL);
-    ug[v5] = VertexProperties(5, 2.5, NORMAL_PIXEL);
-    ug[v7] = VertexProperties(7, 2., NORMAL_PIXEL);
-    ug[v9] = VertexProperties(9, 2.5, TOP_PIXEL);
-    ug[v11] = VertexProperties(11, 2, NORMAL_PIXEL);
-    ug[v12] = VertexProperties(12, 1.5, NORMAL_PIXEL);
-    ug[v13] = VertexProperties(13, 1.5, NORMAL_PIXEL);
-    ug[v14] = VertexProperties(14, 1, TOP_PIXEL);
-    ug[v15] = VertexProperties(15, 1, NORMAL_PIXEL);
-    ug[v16] = VertexProperties(16, 1, NORMAL_PIXEL);
-    ug[v17] = VertexProperties(17, 1, NORMAL_PIXEL);
-    ug[v18] = VertexProperties(18, 1.5, TOP_PIXEL);
-    ug[v19] = VertexProperties(19, 1.5, NORMAL_PIXEL);
-    ug[v20] = VertexProperties(20, 1.5, NORMAL_PIXEL);
-    ug[v21] = VertexProperties(21, 1, TOP_PIXEL);
-    ug[v22] = VertexProperties(22, 1, NORMAL_PIXEL);
-    ug[v23] = VertexProperties(23, 1, NORMAL_PIXEL);
-    ug[v24] = VertexProperties(24, 2, NORMAL_PIXEL);
-    ug[v25] = VertexProperties(25, 2, NORMAL_PIXEL);
-    ug[v26] = VertexProperties(26, 1.5, TOP_PIXEL);
-    ug[v27] = VertexProperties(27, 1.5, NORMAL_PIXEL);
-    ug[v28] = VertexProperties(28, 1.5, NORMAL_PIXEL);
-    ug[v29] = VertexProperties(29, 1, TOP_PIXEL);
-    ug[v30] = VertexProperties(30, 1, TOP_PIXEL);
-    ug[v31] = VertexProperties(31, 2, NORMAL_PIXEL);
-    ug[v32] = VertexProperties(32, 2, NORMAL_PIXEL);
-    ug[v33] = VertexProperties(33, 2, NORMAL_PIXEL);
-    ug[v34] = VertexProperties(34, 1.5, TOP_PIXEL);
-    ug[v35] = VertexProperties(35, 1.5, NORMAL_PIXEL);
-    ug[v36] = VertexProperties(36, 1.5, TOP_PIXEL);
-    ug[v37] = VertexProperties(37, 1.5, NORMAL_PIXEL);
+	if(edge_number == 11){
+		vertex_to v0 = boost::add_vertex(og);
+		vertex_to v1 = boost::add_vertex(og);
+		vertex_to v2 = boost::add_vertex(og);
+		vertex_to v3 = boost::add_vertex(og);
+		vertex_to v4 = boost::add_vertex(og);
+		vertex_to v5 = boost::add_vertex(og);
+		vertex_to v6 = boost::add_vertex(og);
+		vertex_to v7 = boost::add_vertex(og);
+		vertex_to v8 = boost::add_vertex(og);
+		vertex_to v9 = boost::add_vertex(og);
+		vertex_to v10 = boost::add_vertex(og);
 
+		add_edge(v1, v0, EdgeProperties(1.), og);
+		add_edge(v2, v0, EdgeProperties(1.), og);
+		add_edge(v3, v0, EdgeProperties(1.), og);
+		add_edge(v1, v2, EdgeProperties(1.), og);
+		add_edge(v4, v1, EdgeProperties(1.), og);
+		add_edge(v5, v1, EdgeProperties(1.), og);
+		add_edge(v6, v1, EdgeProperties(1.), og);
+		add_edge(v6, v2, EdgeProperties(1.), og);
+		add_edge(v2, v3, EdgeProperties(1.), og);
+		add_edge(v9, v3, EdgeProperties(1.), og);
+		add_edge(v10, v3, EdgeProperties(1.), og);
+		add_edge(v4, v5, EdgeProperties(1.), og);
+		add_edge(v5, v6, EdgeProperties(1.), og);
+		add_edge(v7, v4, EdgeProperties(1.), og);
+		add_edge(v8, v4, EdgeProperties(1.), og);
+		add_edge(v7, v8, EdgeProperties(1.), og);
+		add_edge(v9, v10, EdgeProperties(1.), og);
+
+		og[v6] = VertexProperties(6, 1.5, NORMAL_PIXEL);
+		og[v8] = VertexProperties(8, 1., NORMAL_PIXEL);
+		og[v10] = VertexProperties(10, 1.5, NORMAL_PIXEL);
+		og[v0] = VertexProperties(0, 3, NORMAL_PIXEL);
+		og[v1] = VertexProperties(1, 2, NORMAL_PIXEL);
+		og[v2] = VertexProperties(2, 2, NORMAL_PIXEL);
+		og[v3] = VertexProperties(3, 2, NORMAL_PIXEL);
+		og[v4] = VertexProperties(4, 1.5, NORMAL_PIXEL);
+		og[v5] = VertexProperties(5, 1.5, NORMAL_PIXEL);
+		og[v7] = VertexProperties(7, 1., TOP_PIXEL);
+		og[v9] = VertexProperties(9, 1.5, TOP_PIXEL);
+		
+	} else if(edge_number == 38){
+		
+		vertex_to v0 = boost::add_vertex(og);
+		vertex_to v1 = boost::add_vertex(og);
+		vertex_to v2 = boost::add_vertex(og);
+		vertex_to v3 = boost::add_vertex(og);
+		vertex_to v4 = boost::add_vertex(og);
+		vertex_to v5 = boost::add_vertex(og);
+		vertex_to v6 = boost::add_vertex(og);
+		vertex_to v7 = boost::add_vertex(og);
+		vertex_to v8 = boost::add_vertex(og);
+		vertex_to v9 = boost::add_vertex(og);
+		vertex_to v10 = boost::add_vertex(og);
+		vertex_to v11 = boost::add_vertex(og);
+		vertex_to v12 = boost::add_vertex(og);
+		vertex_to v13 = boost::add_vertex(og);
+		vertex_to v14 = boost::add_vertex(og);
+		vertex_to v15 = boost::add_vertex(og);
+		vertex_to v16 = boost::add_vertex(og);
+		vertex_to v17 = boost::add_vertex(og);
+		vertex_to v18 = boost::add_vertex(og);
+		vertex_to v19 = boost::add_vertex(og);
+		vertex_to v20 = boost::add_vertex(og);
+		vertex_to v21 = boost::add_vertex(og);
+		vertex_to v22 = boost::add_vertex(og);
+		vertex_to v23 = boost::add_vertex(og);
+		vertex_to v24 = boost::add_vertex(og);
+		vertex_to v25 = boost::add_vertex(og);
+		vertex_to v26 = boost::add_vertex(og);
+		vertex_to v27 = boost::add_vertex(og);
+		vertex_to v28 = boost::add_vertex(og);
+		vertex_to v29 = boost::add_vertex(og);
+		vertex_to v30 = boost::add_vertex(og);
+		vertex_to v31 = boost::add_vertex(og);
+		vertex_to v32 = boost::add_vertex(og);
+		vertex_to v33 = boost::add_vertex(og);
+		vertex_to v34 = boost::add_vertex(og);
+		vertex_to v35 = boost::add_vertex(og);
+		vertex_to v36 = boost::add_vertex(og);
+		vertex_to v37 = boost::add_vertex(og);
+		
+		add_edge(v1, v0, EdgeProperties(1.), og);
+		add_edge(v2, v0, EdgeProperties(1.), og);
+		add_edge(v3, v0, EdgeProperties(1.), og);
+		add_edge(v1, v2, EdgeProperties(1.), og);
+		add_edge(v4, v1, EdgeProperties(1.), og);
+		add_edge(v5, v1, EdgeProperties(1.), og);
+		add_edge(v6, v1, EdgeProperties(1.), og);
+		add_edge(v6, v2, EdgeProperties(1.), og);
+		add_edge(v2, v3, EdgeProperties(1.), og);
+		add_edge(v9, v3, EdgeProperties(1.), og);
+		add_edge(v10, v3, EdgeProperties(1.), og);
+		add_edge(v4, v5, EdgeProperties(1.), og);
+		add_edge(v5, v6, EdgeProperties(1.), og);
+		add_edge(v7, v4, EdgeProperties(1.), og);
+		add_edge(v8, v4, EdgeProperties(1.), og);
+		add_edge(v7, v8, EdgeProperties(1.), og);
+		add_edge(v9, v10, EdgeProperties(1.), og);
+		add_edge(v8, v11, EdgeProperties(1.), og);
+		add_edge(v11, v4, EdgeProperties(1.), og);
+		add_edge(v12, v13, EdgeProperties(1.), og);
+		add_edge(v12, v7, EdgeProperties(1.), og);
+		add_edge(v13, v7, EdgeProperties(1.), og);
+		add_edge(v14, v15, EdgeProperties(1.), og);
+		add_edge(v14, v12, EdgeProperties(1.), og);
+		add_edge(v15, v16, EdgeProperties(1.), og);
+		add_edge(v15, v12, EdgeProperties(1.), og);
+		add_edge(v16, v17, EdgeProperties(1.), og);
+		add_edge(v16, v12, EdgeProperties(1.), og);
+		add_edge(v17, v12, EdgeProperties(1.), og);
+		add_edge(v18, v19, EdgeProperties(1.), og);
+		add_edge(v18, v8, EdgeProperties(1.), og);
+		add_edge(v19, v20, EdgeProperties(1.), og);
+		add_edge(v19, v8, EdgeProperties(1.), og);
+		add_edge(v20, v8, EdgeProperties(1.), og);
+		add_edge(v21, v22, EdgeProperties(1.), og);
+		add_edge(v21, v19, EdgeProperties(1.), og);
+		add_edge(v22, v23, EdgeProperties(1.), og);
+		add_edge(v22, v19, EdgeProperties(1.), og);
+		add_edge(v23, v19, EdgeProperties(1.), og);
+		add_edge(v24, v25, EdgeProperties(1.), og);
+		add_edge(v24, v6, EdgeProperties(1.), og);
+		add_edge(v25, v6, EdgeProperties(1.), og);
+		add_edge(v26, v11, EdgeProperties(1.), og);
+		add_edge(v26, v27, EdgeProperties(1.), og);
+		add_edge(v26, v24, EdgeProperties(1.), og);
+		add_edge(v27, v24, EdgeProperties(1.), og);
+		add_edge(v28, v25, EdgeProperties(1.), og);
+		add_edge(v29, v27, EdgeProperties(1.), og);
+		add_edge(v29, v28, EdgeProperties(1.), og);
+		add_edge(v30, v27, EdgeProperties(1.), og);
+		add_edge(v30, v28, EdgeProperties(1.), og);
+		add_edge(v31, v32, EdgeProperties(1.), og);
+		add_edge(v31, v10, EdgeProperties(1.), og);
+		add_edge(v32, v33, EdgeProperties(1.), og);
+		add_edge(v32, v10, EdgeProperties(1.), og);
+		add_edge(v33, v10, EdgeProperties(1.), og);
+		add_edge(v34, v31, EdgeProperties(1.), og);
+		add_edge(v34, v35, EdgeProperties(1.), og);
+		add_edge(v35, v31, EdgeProperties(1.), og);
+		add_edge(v35, v32, EdgeProperties(1.), og);
+		add_edge(v36, v32, EdgeProperties(1.), og);
+		add_edge(v36, v37, EdgeProperties(1.), og);
+		add_edge(v36, v33, EdgeProperties(1.), og);
+		add_edge(v37, v33, EdgeProperties(1.), og);
+
+		og[v6] = VertexProperties(6, 2.5, NORMAL_PIXEL);
+		og[v8] = VertexProperties(8, 2., NORMAL_PIXEL);
+		og[v10] = VertexProperties(10, 2.5, NORMAL_PIXEL);
+		og[v0] = VertexProperties(0, 4, NORMAL_PIXEL);
+		og[v1] = VertexProperties(1, 3, NORMAL_PIXEL);
+		og[v2] = VertexProperties(2, 3, NORMAL_PIXEL);
+		og[v3] = VertexProperties(3, 3, NORMAL_PIXEL);
+		og[v4] = VertexProperties(4, 2.5, NORMAL_PIXEL);
+		og[v5] = VertexProperties(5, 2.5, NORMAL_PIXEL);
+		og[v7] = VertexProperties(7, 2., NORMAL_PIXEL);
+		og[v9] = VertexProperties(9, 2.5, TOP_PIXEL);
+		og[v11] = VertexProperties(11, 2, NORMAL_PIXEL);
+		og[v12] = VertexProperties(12, 1.5, NORMAL_PIXEL);
+		og[v13] = VertexProperties(13, 1.5, NORMAL_PIXEL);
+		og[v14] = VertexProperties(14, 1, TOP_PIXEL);
+		og[v15] = VertexProperties(15, 1, NORMAL_PIXEL);
+		og[v16] = VertexProperties(16, 1, NORMAL_PIXEL);
+		og[v17] = VertexProperties(17, 1, NORMAL_PIXEL);
+		og[v18] = VertexProperties(18, 1.5, TOP_PIXEL);
+		og[v19] = VertexProperties(19, 1.5, NORMAL_PIXEL);
+		og[v20] = VertexProperties(20, 1.5, NORMAL_PIXEL);
+		og[v21] = VertexProperties(21, 1, TOP_PIXEL);
+		og[v22] = VertexProperties(22, 1, NORMAL_PIXEL);
+		og[v23] = VertexProperties(23, 1, NORMAL_PIXEL);
+		og[v24] = VertexProperties(24, 2, NORMAL_PIXEL);
+		og[v25] = VertexProperties(25, 2, NORMAL_PIXEL);
+		og[v26] = VertexProperties(26, 1.5, TOP_PIXEL);
+		og[v27] = VertexProperties(27, 1.5, NORMAL_PIXEL);
+		og[v28] = VertexProperties(28, 1.5, NORMAL_PIXEL);
+		og[v29] = VertexProperties(29, 1, TOP_PIXEL);
+		og[v30] = VertexProperties(30, 1, TOP_PIXEL);
+		og[v31] = VertexProperties(31, 2, NORMAL_PIXEL);
+		og[v32] = VertexProperties(32, 2, NORMAL_PIXEL);
+		og[v33] = VertexProperties(33, 2, NORMAL_PIXEL);
+		og[v34] = VertexProperties(34, 1.5, TOP_PIXEL);
+		og[v35] = VertexProperties(35, 1.5, NORMAL_PIXEL);
+		og[v36] = VertexProperties(36, 1.5, TOP_PIXEL);
+		og[v37] = VertexProperties(37, 1.5, NORMAL_PIXEL);
+		
+	}else{
+		std::cout<<"Le type de artificiel graphe choisi n'existe pas ! "<<std::endl;
+	}
 }
 
 void modify_file_paths(std::string& absolutePath,
@@ -365,7 +236,7 @@ void modify_file_paths(std::string& absolutePath,
     }
 }
 
-void build_corsen_graph(OrientedGraph& graph)
+/*void build_corsen_graph(OrientedGraph& graph)
 {
     std::string absolutePath(
         "/home/eric/vle/vle-labs/paradevs/src/tests/corsen/data_s/");
@@ -429,6 +300,356 @@ void build_corsen_graph(OrientedGraph& graph)
             graph[og_vertex_list[i]] = VertexProperties(i, 1., NORMAL_PIXEL);
         }
     }
+}*/
+
+void brhtg_source(OrientedGraph *go,int nbr_vertex, int nbr_source, int nbr_v_min, int nbr_v_max, const std::vector<int> &niveau,
+					std::vector<int> &Ram, std::vector<int> &Exu, const std::vector<vertex_to> &Vertexs,
+					int nbr_passe, int nbr_npb){
+
+	int nbr_voisin;
+
+	int niv=1;
+	for(int j =0; j<niveau.size()-1; j++){
+		niv *= niveau.at(j);
+	}
+
+	int niv_tot=1;
+	for(int j =0; j<niveau.size(); j++){
+		niv_tot *= niveau.at(j);
+	}
+
+	for(int b = 0; b<niv; b++){
+		std::vector<int> branche;
+		int cpt = 0;
+		while(cpt != niveau.at(niveau.size()-1)+1){
+			branche.push_back((b*niveau.at(niveau.size()-1)+cpt)*nbr_npb);
+			cpt++;
+		}
+
+		for(int i =0; i<branche.size()-1;i++){
+			for(int j = branche.at(i); j<branche.at(i+1); j++){
+				if(j==branche.at(branche.size()-1)-1){
+					break;
+				}
+				else{
+					nbr_voisin = rand_fini(nbr_v_min, nbr_v_max+1);
+					int cpt=0;
+					Entiers ensemble;
+					int cpt_nbr_s = 0;
+					while(cpt!=nbr_voisin){
+						int val;
+						if(j<branche.at(i)+nbr_source){ // Les sommets sont des sources donc imossible de recevoir des données
+							val = rand_fini(j + nbr_source, j + nbr_v_max + nbr_passe);
+						}
+						else if(j>=branche.at(i)+nbr_npb-nbr_passe && i!= (branche.size()-2)){ // Les sommets sont en fin de branche, nécessité de raccordement avec les autres branches
+							val = rand_fini(branche.at(branche.size()-1)-4, branche.at(branche.size()-1));
+						}
+						else if(j>=branche.at(i)+nbr_npb-nbr_passe && i== (branche.size()-2)){ // Les sommets sont proche de l'exutoire
+							val = rand_fini(j+1,branche.at(branche.size()-1));
+						}
+						else{ // Les sommets sont en plein milieu d'une branche
+							val = rand_fini(j+1, j+nbr_passe);
+						}
+
+						if(In_tab(ensemble,val)!=1){
+							ensemble.push_back(val);
+							boost::add_edge(Vertexs.at(j), Vertexs.at(val), EdgeProperties(1.), *go);
+							cpt++;
+						}
+						else{
+							if((nbr_vertex-j)==cpt)
+								break;
+							else
+								cpt_nbr_s++;
+						}
+
+						if(cpt_nbr_s>2*nbr_passe)
+							break;
+					}
+
+				}
+			}
+		}
+
+		for(int i =0; i<branche.size()-1; i++){
+			for(int j = branche.at(i)+nbr_source; j<branche.at(i+1); j++){
+				(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
+			}
+		}
+
+		for(int i =0; i<branche.size()-1; i++){
+			for(int j = branche.at(i); j<branche.at(i)+nbr_source; j++){
+				(*go)[Vertexs.at(j)] = VertexProperties(j, 1, TOP_PIXEL);
+			}
+		}
+
+		Ram.push_back((niv_tot+b)*nbr_npb);
+		Exu.push_back(branche.at(branche.size()-1)-1);
+	}
+
+	Ram.push_back(Ram.at(Ram.size()-1)+nbr_npb);
+
+	if(niveau.size()>1){
+		nbr_voisin = 2;
+		for(int k =0; k<Exu.size(); k++){
+			for(int l = Exu.at(k)-2; l<Exu.at(k)+1; l++){
+				int cpt=0;
+				Entiers ensemble;
+				int cpt_nbr_s = 0;
+				while(cpt!=nbr_voisin){
+					int val = rand_fini(Ram.at(k),Ram.at(k)+2);
+
+					if(In_tab(ensemble,val)!=1){
+						ensemble.push_back(val);
+						boost::add_edge(Vertexs.at(l), Vertexs.at(val), EdgeProperties(1.), *go);
+						cpt++;
+					}
+					else{
+						if((nbr_vertex-l)==cpt)
+							break;
+						else
+							cpt_nbr_s++;
+					}
+
+					if(cpt_nbr_s>2*nbr_passe)
+						break;
+				}
+			}
+		}
+	}
 }
 
+void brhtg_ramification(OrientedGraph *go, int nbr_vertex, int nbr_v_min, int nbr_v_max, const std::vector<int> &niveau,
+					std::vector<int> &Ram, std::vector<int> &Exu, const std::vector<vertex_to> &Vertexs,
+					int nbr_passe, int nbr_npb){
+
+	int nbr_voisin;
+	int cpt_ram = 1;
+	while(cpt_ram != niveau.size()-1){
+		int niv=1;
+		for(int j =0; j<niveau.size()-1-cpt_ram; j++){
+			niv *= niveau.at(j);
+		}
+
+		int niv_tot=0;
+		for(int i =0; i<=cpt_ram; i++){
+			int tmp_niv_tot=1;
+			for(int j =0; j<niveau.size()-i; j++){
+				tmp_niv_tot *= niveau.at(j);
+			}
+			niv_tot+=tmp_niv_tot;
+		}
+
+		std::vector<std::vector<int> > branche;
+		int cpt_b=0;
+		for(int j = 0; j<(Ram.size()-1)/niveau.at(niveau.size()-1-cpt_ram); j++){
+			std::vector<int> tmp_branche;
+			for(int i =0; i< niveau.at(niveau.size()-1-cpt_ram); i++){
+				tmp_branche.push_back(Ram.at(i+cpt_b));
+			}
+			tmp_branche.push_back(tmp_branche.at(tmp_branche.size()-1)+nbr_npb);
+			branche.push_back(tmp_branche);
+			cpt_b+=niveau.at(niveau.size()-1-cpt_ram);
+		}
+
+		Ram.clear();
+		Exu.clear();
+
+		for(int b = 0; b<niv; b++){
+
+			for(int i =0; i<branche.at(b).size()-1;i++){
+				for(int j = branche.at(b).at(i); j<branche.at(b).at(i+1); j++){
+					if(j==branche.at(b).at(branche.at(b).size()-1)-1){
+						break;
+					}
+					else{
+						nbr_voisin = rand_fini(nbr_v_min, nbr_v_max+1);
+						int cpt=0;
+						Entiers ensemble;
+						int cpt_nbr_s = 0;
+						while(cpt!=nbr_voisin){
+							int val;
+
+							if(j>=branche.at(b).at(i)+nbr_npb-nbr_passe && i!= (branche.at(b).size()-2)){ // Les sommets sont en fin de branche, nécessité de raccordement avec les autres branches
+								val = rand_fini(branche.at(b).at(branche.at(b).size()-1)-4, branche.at(b).at(branche.at(b).size()-1));
+							}
+							else if(j>=branche.at(b).at(i)+nbr_npb-nbr_passe && i== (branche.at(b).size()-2)){ // Les sommets sont proche de l'exutoire
+								val = rand_fini(j+1,branche.at(b).at(branche.at(b).size()-1));
+							}
+							else{ // Les sommets sont en plein milieu d'une branche
+								val = rand_fini(j+1, j+nbr_passe);
+							}
+
+							if(In_tab(ensemble,val)!=1){
+								ensemble.push_back(val);
+								boost::add_edge(Vertexs.at(j), Vertexs.at(val), EdgeProperties(1.), *go);
+								cpt++;
+							}
+							else{
+								if((nbr_vertex-j)==cpt)
+									break;
+								else
+									cpt_nbr_s++;
+							}
+
+							if(cpt_nbr_s>2*nbr_passe)
+								break;
+						}
+
+					}
+				}
+			}
+			Ram.push_back((niv_tot+b)*nbr_npb);
+			Exu.push_back(branche.at(b).at(branche.at(b).size()-1)-1);
+
+			for(int y =0; y<branche.at(b).size()-1; y++){
+				for(int x = branche.at(b).at(y); x<branche.at(b).at(y+1); x++){
+					(*go)[Vertexs.at(x)] = VertexProperties(x, 1, NORMAL_PIXEL);
+				}
+			}
+		}
+
+		Ram.push_back(Ram.at(Ram.size()-1)+nbr_npb);
+
+		nbr_voisin = 2;
+		for(int k =0; k<Exu.size(); k++){
+			for(int l = Exu.at(k)-1; l<Exu.at(k)+1; l++){
+				int cpt=0;
+				Entiers ensemble;
+				int cpt_nbr_s = 0;
+				while(cpt!=nbr_voisin){
+					int val = rand_fini(Ram.at(k),Ram.at(k)+2);
+
+					if(In_tab(ensemble,val)!=1){
+						ensemble.push_back(val);
+						boost::add_edge(Vertexs.at(l), Vertexs.at(val), EdgeProperties(1.), *go);
+						cpt++;
+					}
+					else{
+						if((nbr_vertex-l)==cpt)
+							break;
+						else
+							cpt_nbr_s++;
+					}
+
+					if(cpt_nbr_s>2*nbr_passe)
+						break;
+				}
+			}
+		}
+		cpt_ram++;
+	}
+}
+
+void brhtg_exutoire(OrientedGraph *go,int nbr_vertex,int nbr_v_min, int nbr_v_max,
+		std::vector<int> &Ram, const std::vector<vertex_to> &Vertexs,
+		int nbr_passe){
+
+	int nbr_voisin;
+	Ram.at(Ram.size()-1)=nbr_vertex;
+
+	for(int i =0; i<Ram.size()-1;i++){
+		for(int j = Ram.at(i); j<Ram.at(i+1); j++){
+			if(j==Ram.at(Ram.size()-1)-1){
+				(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
+				break;
+			}
+			else{
+				if(Ram.at(i+1)-j<nbr_passe)
+					nbr_voisin = 2;
+				else
+					nbr_voisin = rand_fini(nbr_v_min, nbr_v_max+1);
+				int cpt=0;
+				Entiers ensemble;
+				int cpt_nbr_s = 0;
+				while(cpt!=nbr_voisin){
+					int val;
+
+					if(j>=Ram.at(i+1)-nbr_passe && i!=Ram.size()-2){ // Les sommets sont proche de l'exutoire
+						val = rand_fini(Ram.at(Ram.size()-1)-4,Ram.at(Ram.size()-1));
+					}
+					else if(j>=Ram.at(i+1)-nbr_passe && i==Ram.size()-2){ // Les sommets sont proche de l'exutoire
+						val = rand_fini(j+1,Ram.at(Ram.size()-1));
+					}
+					else{ // Les sommets sont en plein milieu d'une branche
+						val = rand_fini(j+1, j+nbr_passe);
+					}
+
+					if(In_tab(ensemble,val)!=1&& j!=val){
+						ensemble.push_back(val);
+						boost::add_edge(Vertexs.at(j), Vertexs.at(val), EdgeProperties(1.), *go);
+						cpt++;
+					}
+					else{
+						if((nbr_vertex-j)==cpt)
+							break;
+						else
+							cpt_nbr_s++;
+					}
+
+					if(cpt_nbr_s>2*nbr_passe)
+						break;
+				}
+
+			}
+			(*go)[Vertexs.at(j)] = VertexProperties(j, 1, NORMAL_PIXEL);
+		}
+	}
+}
+
+
+void build_generator_graph(OrientedGraph *go, int nbr_vertex, int nbr_source, int nbr_v_min, int nbr_v_max,const std::vector<int> &niveau){
+	std::vector<vertex_to> Vertexs;
+
+	int nbr_npb;
+	int nbr_branche = 0;
+	int nbr_passe = 4;
+
+	for(int i =0; i<nbr_vertex; i++){
+		vertex_to vo = boost::add_vertex(*go);
+		Vertexs.push_back(vo);
+	}
+
+	// Calcul du nombre de branches à partir de l'information des niveaux
+	for(int i =0; i< niveau.size(); i++){
+		int nbr_tmp =1;
+		for(int j =0; j<=i; j++){
+			nbr_tmp *= niveau.at(j);
+		}
+		nbr_branche += nbr_tmp;
+	}
+
+	nbr_npb = nbr_vertex/(nbr_branche);
+
+	std::vector<int> Ram;
+	std::vector<int> Exu;
+
+	if(niveau.size()>1){
+	/*
+	 * *** Code Source ***
+	 */
+
+	brhtg_source(go,nbr_vertex,nbr_source,nbr_v_min,nbr_v_max,niveau,Ram,Exu,Vertexs,nbr_passe,nbr_npb);
+
+	/*
+	 * *** Code Ramifications ***
+	 */
+
+	brhtg_ramification(go,nbr_vertex,nbr_v_min,nbr_v_max,niveau,
+			Ram,Exu,Vertexs,nbr_passe,nbr_npb);
+
+	/*
+	 * *** Code Exutoire ***
+	 */
+
+	brhtg_exutoire(go,nbr_vertex,nbr_v_min,nbr_v_max,
+				Ram,Vertexs,nbr_passe);
+				
+	} else {
+			brhtg_source(go,nbr_vertex,nbr_source,nbr_v_min,nbr_v_max,niveau,Ram,Exu,Vertexs,nbr_passe,nbr_npb);
+	}
+
+}
+
+
 } } } // namespace paradevs tests boost_graph

+ 5 - 4
src/tests/boost_graph/partitioning/graph_build.hpp

@@ -28,12 +28,13 @@
 #define TESTS_BOOST_GRAPH_PARTITIONING_GRAPH_BUILD_H
 
 #include <tests/boost_graph/partitioning/defs.hpp>
-
+#include <tests/boost_graph/partitioning/utils.hpp>
 namespace paradevs { namespace tests { namespace boost_graph {
 
-void build_graph(UnorientedGraph& g, OrientedGraph& graph);
-void build_corsen_graph(OrientedGraph& graph);
+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,const std::vector<int> &niveau);
+//void build_corsen_graph(OrientedGraph& graph);
 
-} } } // namespace paradevs tests boost_graph
+} } } // namespace paradevs tests boost_graph;
 
 #endif

+ 76 - 71
src/tests/boost_graph/partitioning/main.cpp

@@ -26,8 +26,9 @@
 
 #include <tests/boost_graph/partitioning/gggp.hpp>
 #include <tests/boost_graph/partitioning/graph_build.hpp>
-
+#include <boost/graph/copy.hpp>
 #include <boost/timer.hpp>
+#include <fstream>
 
 #include <iostream>
 
@@ -45,88 +46,92 @@ int main()
 
     srand((unsigned)time(NULL));
 
-    UnorientedGraph* g = new UnorientedGraph();
+	UnorientedGraph* g = new UnorientedGraph();
     OrientedGraph* go = new OrientedGraph();
-    UnorientedGraph* graph_origin = new UnorientedGraph();
-    OrientedGraph* gop = new OrientedGraph();
-
-    build_graph(*g, *go);
-    build_graph(*graph_origin, *gop);
-
-    delete gop;
-
+    UnorientedGraph graph_origin;
+    std::vector<std::string> color;
+    color.push_back("node [color=lightblue2, style=filled];");
+    color.push_back("node [color=red, style=filled];");
+    color.push_back("node [color=limegreen, style=filled];");
+    color.push_back("node [color=orange, style=filled];");
+    color.push_back("node [color=yellow2, style=filled];");
+    color.push_back("node [color=slateblue1, style=filled];");
+    color.push_back("node [color=plum, style=filled];");
+    color.push_back("node [color=black, style=filled];");
+    color.push_back("node [color=dimgrey, style=filled];");
+    color.push_back("node [color=gold, style=filled];");
+    color.push_back("node [color=indigo, style=filled];");
+    color.push_back("node [color=turquoise, style=filled];");
+    color.push_back("node [color=olive, style=filled];");
+    color.push_back("node [color=cyan, style=filled];");
+    color.push_back("node [color=crimson, style=filled];");
+    color.push_back("node [color=lightsalmon, style=filled];");
     int nbr_parties = 4;
-
-    /*EntiersEntiers Partition = Random_partitioning(g,nbr_parties);
-
-    for(uint i = 0; i < Partition.size(); i++){
-    	for(uint j = 0; j < Partition.at(i)->size(); j++){
-    		std::cout<<Partition.at(i)->at(j)<<std::endl;
-    	}
-    	std::cout<<std::endl;
-    }
-
-    std::cout<<Partition.size()<<std::endl;*/
+    
 
     Edges edge_partie;
     OutputEdgeList outputedgeslist(nbr_parties);
     InputEdgeList inputedgelist;
     Connections connections;
-
-    std::cout<<num_vertices(*g)/4<<std::endl;
-
-    OrientedGraphs graphs = Multiniveau(num_vertices(*g)/2, g, graph_origin, go, nbr_parties,"rand", "gggp_pond",
-                                        "cut_norm", "norm", edge_partie ,
+    
+    build_graph(*go, 38);
+    Entiers niveau;
+    niveau.push_back(3);
+    niveau.push_back(2);
+    niveau.push_back(3);
+    
+    //build_generator_graph(go, 2000, 10 , 2 , 5 ,niveau);
+    make_unoriented_graph(*go, *g);
+    boost::copy_graph(*g, graph_origin);
+    
+    /*std::ofstream fichier ("../../sortie_graphe/graph_38_4.txt", std::ios::out);
+    fichier<<"digraph G {"<<std::endl;
+    tie(vertexIto, vertexEndo) = vertices(*go);
+    for (; vertexIto != vertexEndo; ++vertexIto) {
+    	fichier<<(*go)[*vertexIto]._index<<"-> {";
+    	tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
+    			*go);
+    	for (; neighbourIto != neighbourEndo; ++neighbourIto){
+    		fichier<<(*go)[*neighbourIto]._index<<";";
+    	}
+    	fichier<<"}"<<std::endl;
+    }
+	fichier<<"}";
+	fichier.close();*/
+    
+    int niveau_contraction = num_vertices(*g)/1;
+    
+    OrientedGraphs graphs = Multiniveau(niveau_contraction, g, &graph_origin, go, nbr_parties, niveau_contraction/4,"HEM", "gggp",
+                                        "cut", "ratio", edge_partie ,
                                         outputedgeslist, inputedgelist,
                                         connections);
 
-    std::cout << std::endl;
-    std::cout << "Sous Graphes :" << std::endl;
-    for (uint i = 0; i< graphs.size(); i++) {
-        tie(vertexIto, vertexEndo) = vertices(graphs[i]);
-        for (; vertexIto != vertexEndo; ++vertexIto) {
-            std::cout << graphs[i][*vertexIto]._index
-                      << " est connecté avec ";
-            tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
-                                                                 graphs[i]);
-            for (; neighbourIto != neighbourEndo; ++neighbourIto)
-                std::cout << graphs[i][*neighbourIto]._index << " ";
-            std::cout << " et son poids est de "
-                      << graphs[i][*vertexIto]._weight<<std::endl;
-        }
-        std::cout << std::endl;
-    }
-
-    std::clog << "OutputEdgeList :" << std::endl;
-    for (uint i = 0; i < outputedgeslist.size(); i++) {
-        for (uint j = 0; j < outputedgeslist.at(i).size(); j++){
-            std::cout << outputedgeslist.at(i).at(j).first << " "
-                      << outputedgeslist.at(i).at(j).second << std::endl;
-        }
-    }
-    std::cout << std::endl;
 
-    std::clog << "InputEdgeList :" << std::endl;
-    for (uint i = 0; i < inputedgelist.size(); i++) {
-        for (uint j = 0; j < inputedgelist.at(i).size(); j++){
-            std::cout << inputedgelist.at(i).at(j).first << " "
-                      << inputedgelist.at(i).at(j).second << std::endl;
-        }
-    }
-    std::cout << std::endl;
+                
+   /*for(int i =0; i<graphs.size(); i++){
+	    fichier2<<color.at(i)<<std::endl; 
+		tie(vertexIto, vertexEndo) = vertices(graphs.at(i));
+		for (; vertexIto != vertexEndo; ++vertexIto) {
+			fichier2<<(graphs.at(i))[*vertexIto]._index<<"-> {";
+			//std::cout<<(graphs.at(i))[*vertexIto]._index<<" est connecté avec : ";
+			tie(neighbourIto, neighbourEndo) = adjacent_vertices(*vertexIto,
+					graphs.at(i));
+			for (; neighbourIto != neighbourEndo; ++neighbourIto){
+				fichier2<<(graphs.at(i))[*neighbourIto]._index<<";";
+				//std::cout<<(graphs.at(i))[*neighbourIto]._index<<" ";
+			}
+			fichier2<<"}"<<std::endl;
+			//std::cout<<std::endl;
+		}
+		fichier2<<std::endl;
+		//std::cout<<std::endl;
+	}
+	fichier2<<"}"<<std::endl;
+	fichier2.close();
+	*/
 
-    std::clog << "Connections :" << std::endl;
-    for (uint i = 0; i < connections.size(); i++) {
-        std::cout << "(" << connections.at(i).first.first << ","
-                  << connections.at(i).first.second << ") -> ("
-                  << connections.at(i).second.first << ","
-                  << connections.at(i).second.second << ")"
-                  << std::endl;
-    }
 
-	delete graph_origin;
 	delete go;
-
-    std::cout << "Duration : " << t.elapsed() << " seconds" << std::endl;
-
+	
+	std::cout << "Duration : " << t.elapsed() << " seconds" << std::endl;
 }

+ 49 - 4
src/tests/boost_graph/partitioning/utils.cpp

@@ -1152,7 +1152,7 @@ double Cut_one_cluster(const Entiers &cluster, UnorientedGraph &g, std::string n
 		bool found;
 		double cpt=0.;
 		for(uint i=0;i<cluster.size();i++){
-			tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster[i], g);
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i), g);
 			for (; neighbourIt != neighbourEnd; ++neighbourIt){
 				tie(e1,found)=edge(vertex(cluster[i],g),vertex(*neighbourIt,g),g);
 				if(In_tab(cluster,*neighbourIt)!=1){
@@ -1160,10 +1160,10 @@ double Cut_one_cluster(const Entiers &cluster, UnorientedGraph &g, std::string n
 				}
 			}
 		}
-		double vol = Cluster_Degree(g,cluster);
-		return (cpt/2.)/vol;
+		double deg = Cluster_Degree(g,cluster);
+		return cpt/deg;
 	}
-	else{
+	else if(name == "cut"){
 		edge_t e1;
 		bool found;
 		double cpt=0.;
@@ -1178,6 +1178,24 @@ double Cut_one_cluster(const Entiers &cluster, UnorientedGraph &g, std::string n
 		}
 		return cpt/2.;
 	}
+	else if(name == "ratio"){
+		edge_t e1;
+		bool found;
+		double cpt=0.;
+		for(uint i=0;i<cluster.size();i++){
+			tie(neighbourIt, neighbourEnd) = adjacent_vertices(cluster.at(i), g);
+			for (; neighbourIt != neighbourEnd; ++neighbourIt){
+				tie(e1,found)=edge(vertex(cluster.at(i),g),vertex(*neighbourIt,g),g);
+				if(In_tab(cluster,*neighbourIt)!=1){
+					cpt+=g[e1]._weight;
+				}
+			}
+		}
+		double vol = Cluster_Weight(g,cluster);
+		return cpt/vol;
+	}
+	
+	/*Vérification de la formule : doute sur le /2.*/
 }
 
 double Cut_cluster(const EntiersEntiers &tab_cluster,UnorientedGraph &g,std::string name)
@@ -1372,6 +1390,33 @@ OrientedGraphs Graph_Partition(const EntiersEntiers& Partition,
     return graph_partie;
 }
 
+
+
+double Cluster_Weight(UnorientedGraph &g , const Entiers &cluster)
+{
+    double val = 0.;
+
+    for(uint i = 0; i < cluster.size(); i++){
+        val += g[cluster.at(i)]._weight;;
+    }
+    return val;
+}
+
+double Best_Cut_cluster(EntiersEntiers &tab_cluster,Entiers *cluster1, Entiers *cluster2, int index_cluster1, UnorientedGraph &g,std::string name)
+{
+	tab_cluster.push_back(cluster2);
+	
+	double cpt=0.;
+	for(int i=0;i<tab_cluster.size();i++){
+		if(i!=index_cluster1){
+		cpt+=Cut_one_cluster(*tab_cluster[i],g,name);
+		}
+	}
+	cpt+=Cut_one_cluster(*cluster1,g,name);
+	tab_cluster.pop_back();
+	return cpt;
+}
+
 /*double In_modularity(UnorientedGraph &g , const Entiers &cluster){
 	property_map<UnorientedGraph,edge_weight_t>::type poids_arc=get(edge_weight_t(),g);
 	edge_t e1;

+ 2 - 0
src/tests/boost_graph/partitioning/utils.hpp

@@ -108,6 +108,8 @@ void make_unoriented_graph(const OrientedGraph& og, UnorientedGraph& uog);
 void adjacence_ggp(int vertex, Entiers &sommets_adj, UnorientedGraph *g);
 
 float modif_Cout_coupe(const Entiers &P, int val, float cut, UnorientedGraph *g);
+double Cluster_Weight(UnorientedGraph &g , const Entiers &cluster);
+double Best_Cut_cluster(EntiersEntiers &tab_cluster,Entiers *cluster1, Entiers *cluster2, int index_cluster1, UnorientedGraph &g,std::string name);
 
 } } } // namespace paradevs tests boost_graph
 

+ 109 - 25
src/tests/boost_graph/tests.cpp

@@ -30,6 +30,7 @@
 
 #include <tests/boost_graph/models.hpp>
 #include <tests/boost_graph/graph_builder.hpp>
+#include <tests/boost_graph/graph_generator.hpp>
 #include <tests/boost_graph/graph_manager.hpp>
 #include <tests/boost_graph/graph_partitioning.hpp>
 
@@ -57,7 +58,7 @@ void flat_heap_test(double duration)
     rc.run();
 }
 
-template < class GraphBuilder >
+/*template < class GraphBuilder >
 void flat_vector_test(double duration)
 {
     RootCoordinator <
@@ -75,7 +76,7 @@ void flat_vector_test(double duration)
     > rc(0, duration, "root", NoParameters(), NoParameters());
 
     rc.run();
-}
+}*/
 
 void hierarchical_test()
 {
@@ -95,12 +96,14 @@ void hierarchical_test()
     // rc.run();
 }
 
-void parallel_partitionning_heap_test(double duration,
+/*void parallel_partitionning_heap_test(double duration,
                                       int cluster_number,
                                       std::string partitioning_method_name,
                                       int contraction_coef,
                                       bool contraction_coef_flag)
 {
+	RandomGraphGenerator g(2000);
+	
     RootCoordinator <
         DoubleTime,
         paradevs::pdevs::multithreading::Coordinator <
@@ -114,10 +117,10 @@ void parallel_partitionning_heap_test(double duration,
             PartitioningParameters >
         > rc(0, duration, "root", NoParameters(),
              PartitioningParameters(cluster_number, partitioning_method_name,
-                                    contraction_coef, contraction_coef_flag));
+                                    contraction_coef, contraction_coef_flag, &g));
 
     rc.run();
-}
+}*/
 
 void partitionning_heap_test(double duration,
                              int cluster_number,
@@ -125,6 +128,14 @@ void partitionning_heap_test(double duration,
                              int contraction_coef,
                              bool contraction_coef_flag)
 {
+	std::vector<int> niveau;
+	niveau.push_back(4);
+	niveau.push_back(3);
+	niveau.push_back(2);
+	RandomGraphGenerator g(2000, niveau, 5, 2, 4);
+	//ArtificialGraphGenerator g(38);
+	//CorsenGraphGenerator g;
+	
     RootCoordinator <
         DoubleTime,
         paradevs::pdevs::Coordinator <
@@ -133,22 +144,23 @@ void partitionning_heap_test(double duration,
             SchedulerHandle,
             HeapHierarchicalGraphManager <
                 SchedulerHandle,
-                PartitioningGraphBuilder >,
+                PartitioningGraphBuilder>,
             paradevs::common::NoParameters,
             PartitioningParameters >
         > rc(0, duration, "root", NoParameters(),
              PartitioningParameters(cluster_number, partitioning_method_name,
-                                    contraction_coef, contraction_coef_flag));
+                                    contraction_coef, contraction_coef_flag, &g));
 
     rc.run();
 }
 
-void partitionning_vector_test(double duration,
+/*void partitionning_vector_test(double duration,
                                int cluster_number,
                                std::string partitioning_method_name,
                                int contraction_coef,
                                bool contraction_coef_flag)
 {
+	RandomGraphGenerator g(2000);
     RootCoordinator <
         DoubleTime,
         paradevs::pdevs::Coordinator <
@@ -163,10 +175,10 @@ void partitionning_vector_test(double duration,
             PartitioningParameters >
         > rc(0, duration, "root", NoParameters(),
              PartitioningParameters(cluster_number, partitioning_method_name,
-                                    contraction_coef, contraction_coef_flag));
+                                    contraction_coef, contraction_coef_flag, &g));
 
     rc.run();
-}
+}*/
 
 void test(double duration, std::string partitioning_method_name,
           unsigned int min, unsigned int max, unsigned int step,
@@ -211,10 +223,10 @@ void test(double duration, std::string partitioning_method_name,
                 double t1 = t.elapsed();
 
                 for (unsigned int i = 0; i < 20; ++i) {
-                    partitionning_vector_test(duration, n,
+                    /*partitionning_vector_test(duration, n,
                                               partitioning_method_name,
                                               contraction_coef,
-                                              contraction_coef_flag);
+                                              contraction_coef_flag);*/
                 }
 
                 double t2 = t.elapsed();
@@ -245,10 +257,10 @@ void test(double duration, std::string partitioning_method_name,
             double t1 = t.elapsed();
 
             for (unsigned int i = 0; i < 20; ++i) {
-                partitionning_vector_test(duration, contraction_coef,
+                /*partitionning_vector_test(duration, contraction_coef,
                                           partitioning_method_name,
                                           contraction_coef,
-                                          contraction_coef_flag);
+                                          contraction_coef_flag);*/
                 }
 
             double t2 = t.elapsed();
@@ -260,6 +272,8 @@ void test(double duration, std::string partitioning_method_name,
     }
 }
 
+const double duration_38 = 1000;
+
 void test_flat_38()
 {
     boost::timer t;
@@ -267,25 +281,23 @@ void test_flat_38()
     std::cout << "== 38 nodes ==" << std::endl;
     std::cout << "flat graph with heap = ";
     for (unsigned int i = 0; i < 20; ++i) {
-        flat_heap_test< FlatGraphBuilder >(10000);
+        flat_heap_test< FlatGraphBuilder >(duration_38);
     }
 
     double t2 = t.elapsed();
 
     std::cout << t2 / 20 << std::endl;
 
-    std::cout << "flat graph with vector = ";
+    /*std::cout << "flat graph with vector = ";
     for (unsigned int i = 0; i < 20; ++i) {
-        flat_vector_test< FlatGraphBuilder >(10000);
-    }
+        flat_vector_test< FlatGraphBuilder >(1000);
+    }*/
 
     double t3 = t.elapsed();
 
     std::cout << (t3 - t2) / 20 << std::endl;
 }
 
-const double duration_38 = -1;
-
 void test_partiotining_38()
 {
     for (int i = 1; i <= 2; ++i) {
@@ -299,6 +311,72 @@ void test_partiotining_38()
     }
 }
 
+const double duration_random = 20;
+
+void test_flat_random()
+{
+    boost::timer t;
+
+    std::cout << "== Random Graph ==" << std::endl;
+    std::cout << "flat graph with heap = ";
+    for (unsigned int i = 0; i < 20; ++i) {
+        flat_heap_test< RandomFlatGraphBuilder >(duration_random);
+    }
+
+    double t2 = t.elapsed();
+
+    std::cout << t2 / 20 << std::endl;
+
+    /*std::cout << "flat graph with vector = ";
+    for (unsigned int i = 0; i < 20; ++i) {
+        flat_vector_test< FlatGraphBuilder >(1000);
+    }*/
+
+    double t3 = t.elapsed();
+
+    std::cout << (t3 - t2) / 20 << std::endl;
+}
+
+void test_partiotining_random()
+{
+	test(duration_random, "gggp_pond", 2, 32, 2, false, true, 5, true);
+    test(duration_random, "gggp_pond", 2, 32, 2, false, true, 10, true);
+    test(duration_random, "gggp_pond", 2, 32, 2, false, true, 20, true);
+    test(duration_random, "gggp_pond", 2, 32, 2, false, true, 40, true);
+    test(duration_random, "gggp_pond", 2, 22, 2, false, true, 100, true);
+
+    test(duration_random, "gggp_pond", 2, 32, 2, false, true, 15, false);
+    test(duration_random, "gggp_pond", 2, 32, 2, false, true, 20, false);
+    test(duration_random, "gggp_pond", 2, 32, 2, false, true, 25, false);
+    test(duration_random, "gggp_pond", 2, 32, 2, false, true, 30, false);
+    test(duration_random, "gggp_pond", 2, 32, 2, false, true, 35, false);
+    test(duration_random, "gggp_pond", 2, 32, 2, false, true, 40, false);
+    test(duration_random, "gggp_pond", 2, 32, 2, false, true, 45, false);
+    test(duration_random, "gggp_pond", 2, 32, 2, false, true, 50, false);
+
+    test(duration_random, "ggp", 2, 32, 2, false, true, 5, true);
+    test(duration_random, "ggp", 2, 32, 2, false, true, 10, true);
+    test(duration_random, "ggp", 2, 32, 2, false, true, 20, true);
+    test(duration_random, "ggp", 2, 32, 2, false, true, 40, true);
+    test(duration_random, "ggp", 2, 22, 2, false, true, 100, true);
+
+    test(duration_random, "ggp", 2, 32, 2, false, true, 15, false);
+    test(duration_random, "ggp", 2, 32, 2, false, true, 20, false);
+    test(duration_random, "ggp", 2, 32, 2, false, true, 25, false);
+    test(duration_random, "ggp", 2, 32, 2, false, true, 30, false);
+    test(duration_random, "ggp", 2, 32, 2, false, true, 35, false);
+    test(duration_random, "ggp", 2, 32, 2, false, true, 40, false);
+    test(duration_random, "ggp", 2, 32, 2, false, true, 45, false);
+    test(duration_random, "ggp", 2, 32, 2, false, true, 50, false);
+
+    test(duration_random, "random", 2, 32, 2, false, true, 5, true);
+    test(duration_random, "random", 2, 32, 2, false, true, 10, true);
+    test(duration_random, "random", 2, 32, 2, false, true, 20, true);
+    test(duration_random, "random", 2, 32, 2, false, true, 40, true);
+    test(duration_random, "random", 2, 22, 2, false, true, 100, true);
+
+}
+
 const double corsen_duration = 20;
 
 void test_flat_corsen()
@@ -368,11 +446,17 @@ int main()
 {
     srand(7262);
 
-    // test_flat_38();
-    // test_partiotining_38();
-
-    test_flat_corsen();
-    test_partitioning_corsen();
+    test_flat_38();
+    test_partiotining_38();
+
+    //test_flat_corsen();
+    //test_partitioning_corsen();
+    
+    /*
+     * *** Problème inconnu affiche oups lors de l'exécution (problème hors compétence) ***
+     */
+    test_flat_random();
+    test_partiotining_random();
 
     return 0;
 }