Pārlūkot izejas kodu

Add random partitionning method.
Modification of gggp_pond functions (bug fix).
Add a new random contraction method.
Validation and tests of devs example (38 edges).
Remove console display (segfault error).

Christopher Herbez 10 gadi atpakaļ
vecāks
revīzija
1401786467

+ 3 - 3
src/kernel/pdevs/GraphManager.hpp

@@ -145,13 +145,13 @@ public:
 
     virtual std::string to_string(int level) const
     {
-        std::ostringstream ss;
+    	std::ostringstream ss;
 
-        ss << common::spaces(level * 2) << "Childs:" << std::endl;
+    	/*ss << common::spaces(level * 2) << "Childs :" << std::endl;
         for (auto & child : _child_list) {
             ss << child->to_string(level + 1);
         }
-        ss << _link_list.to_string(level);
+        ss << _link_list.to_string(level);*/
         return ss.str();
     }
 

+ 289 - 6
src/tests/boost_graph/graph_builder.hpp

@@ -54,6 +54,33 @@ public:
         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);
@@ -72,8 +99,54 @@ public:
         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(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[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);
@@ -83,7 +156,47 @@ public:
         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[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);
+
 
         graphs.push_back(graph);
     }
@@ -103,6 +216,74 @@ public:
             OrientedGraph graph;
 
             OrientedGraph::vertex_descriptor v1 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v4 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v5 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v7 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v8 = 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);
+
+            boost::add_edge(v4, v1, 1., graph);
+            boost::add_edge(v5, v1, 1., graph);
+            boost::add_edge(v4, v5, 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(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);
+
+            graph[v8] = VertexProperties(8, 2., NORMAL_PIXEL);
+            graph[v1] = VertexProperties(1, 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[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);
+
+
+            /*OrientedGraph::vertex_descriptor v1 = boost::add_vertex(graph);
             OrientedGraph::vertex_descriptor v2 = boost::add_vertex(graph);
             OrientedGraph::vertex_descriptor v4 = boost::add_vertex(graph);
             OrientedGraph::vertex_descriptor v5 = boost::add_vertex(graph);
@@ -127,7 +308,7 @@ public:
             graph[v2] = VertexProperties(2, 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[v7] = VertexProperties(7, 1., TOP_PIXEL);*/
 
             graphs.push_back(graph);
         }
@@ -136,6 +317,79 @@ public:
             OrientedGraph graph;
 
             OrientedGraph::vertex_descriptor v0 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v2 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v3 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v6 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v9 = boost::add_vertex(graph);
+            OrientedGraph::vertex_descriptor v10 = 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(v2, v0, 1., graph);
+            boost::add_edge(v3, v0, 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(v9, v10 , 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, 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(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, 2.5, NORMAL_PIXEL);
+            graph[v10] = VertexProperties(10, 2.5, NORMAL_PIXEL);
+            graph[v0] = VertexProperties(0, 4, NORMAL_PIXEL);
+            graph[v2] = VertexProperties(2, 3, NORMAL_PIXEL);
+            graph[v3] = VertexProperties(3, 3, NORMAL_PIXEL);
+            graph[v9] = VertexProperties(9, 2.5, TOP_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);
+
+            /*OrientedGraph::vertex_descriptor v0 = boost::add_vertex(graph);
             OrientedGraph::vertex_descriptor v3 = boost::add_vertex(graph);
             OrientedGraph::vertex_descriptor v9 = boost::add_vertex(graph);
             OrientedGraph::vertex_descriptor v10 = boost::add_vertex(graph);
@@ -148,12 +402,13 @@ public:
             graph[v10] = VertexProperties(10, 1., NORMAL_PIXEL);
             graph[v0] = VertexProperties(0, 1., NORMAL_PIXEL);
             graph[v3] = VertexProperties(3, 1., NORMAL_PIXEL);
-            graph[v9] = VertexProperties(9, 1., TOP_PIXEL);
+            graph[v9] = VertexProperties(9, 1., TOP_PIXEL);*/
 
             graphs.push_back(graph);
         }
         {
-            // input S1
+
+            /*// input S1
             input_edges.push_back(InputEdges());
             // input S2
             input_edges.push_back(InputEdges());
@@ -172,7 +427,35 @@ public:
             // parent
             parent_connections.push_back(Connection(Port(1,1),Port(2,0)));
             parent_connections.push_back(Connection(Port(1,2),Port(2,0)));
-            parent_connections.push_back(Connection(Port(1,2),Port(2,3)));
+            parent_connections.push_back(Connection(Port(1,2),Port(2,3)));*/
+
+
+            // input S1
+            input_edges.push_back(InputEdges());
+            input_edges[0].push_back(Edge(6, 1));
+            input_edges[0].push_back(Edge(26, 11));
+            // input S2
+            input_edges.push_back(InputEdges());
+            input_edges[1].push_back(Edge(1, 0));
+            input_edges[1].push_back(Edge(1, 2));
+            input_edges[1].push_back(Edge(5, 6));
+
+            // output S1
+            output_edges.push_back(OutputEdges());
+            output_edges[0].push_back(Edge(1, 0));
+            output_edges[0].push_back(Edge(1, 2));
+            output_edges[0].push_back(Edge(5, 6));
+            // output S2
+            output_edges.push_back(OutputEdges());
+            output_edges[1].push_back(Edge(6, 1));
+            output_edges[1].push_back(Edge(26, 11));
+
+            // parent
+            parent_connections.push_back(Connection(Port(1,1),Port(2,0)));
+            parent_connections.push_back(Connection(Port(1,1),Port(2,2)));
+            parent_connections.push_back(Connection(Port(1,5),Port(2,6)));
+            parent_connections.push_back(Connection(Port(2,6),Port(1,1)));
+            parent_connections.push_back(Connection(Port(2,26),Port(1,11)));
         }
     }
 };

+ 10 - 2
src/tests/boost_graph/graph_partitioning.hpp

@@ -48,10 +48,15 @@ public:
 
         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);
 
-        int nbr_parties = 4;
+        delete gop;
+
+        int nbr_parties = 8;
         Edges edge_partie;
         Connections connections;
 
@@ -63,10 +68,13 @@ public:
 
         output_edges = OutputEdgeList(nbr_parties);
 
-        graphs = Multiniveau(6, g, go, nbr_parties, "gggp_pond",
+        graphs = Multiniveau(num_vertices(*g)/4, g, graph_origin, go, nbr_parties,"rand", "gggp_pond",
                              "cut_norm", "norm", edge_partie ,
                              output_edges, input_edges,
                              parent_connections);
+        //std::cout<<"Sorti ! "<<std::endl;
+
+        delete graph_origin;
 
     }
 };

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

@@ -84,8 +84,15 @@ void gggp(UnorientedGraph *g, Entiers *sommetsSource,
 //		}
         Liste_Voisin(*sommetsDestination, sommets_adj, *g);
         if (sommets_adj.size() == 0) {
-            std::cout<<"Je suis sorti !!!! "<<std::endl;
-            break;
+            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++)
@@ -123,9 +130,9 @@ void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource,
 {
     int val;
     Entiers sommets_adj;
-    if((sommetsSource->size()-1)==0){
+    if(sommetsSource->size()==1){
         val=0;
-        std::cout<<"Entré dans le debug ! "<<std::endl;
+        //std::cout<<"Entré dans le debug ! "<<std::endl;
         Entiers tailles;
         for(uint i=0;i<Partition.size();i++){
             tailles.push_back(Partition.at(i)->size());
@@ -133,12 +140,15 @@ void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource,
         uint tmp=*max_element(tailles.begin(),tailles.end());
         for(uint i=0; i<Partition.size();i++){
             if(Partition.at(i)->size()==tmp)
+            {
                 gggp_pond(g,Partition[i],sommetsDestination,Partition);
-            break;
+            	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
+    	//std::cout<<"val : "<<sommetsSource->at(val)<<std::endl;
     double poids_max=0;
     for(uint i=0;i<sommetsSource->size();i++){
         poids_max+=(*g)[sommetsSource->at(i)]._weight;
@@ -150,25 +160,44 @@ void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource,
     sommetsDestination->push_back(sommetsSource->at(val));
     sommetsSource->erase(sommetsSource->begin() + val);
 
-    if(sommetsSource->size()<2)
-        return;
-
-    while(poids<poids_max)
+   // std::cout<<"taille sommetsSource avant le while : "<<sommetsSource->size()<<std::endl;
+    while(poids<poids_max && sommetsSource->size()>1)
     {
+    	//std::cout<<"taille sommetsSource dans le while "<<sommetsSource->size()<<std::endl;
         Liste_Voisin(*sommetsDestination,sommets_adj,*g);
-        if((sommets_adj.size()==0))
+        if(sommets_adj.size()==0)
         {
-            std::cout<<"Je suis sorti !!!! "<<std::endl;
+            //std::cout<<"Je suis sorti car pas de voisin !!!! "<<std::endl;
+            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{
             sort(sommets_adj.begin(), sommets_adj.end());
 
+            /*std::cout<<"adj :"<<std::endl;
+            for(uint a = 0; a<sommets_adj.size(); a++){
+            	std::cout<<sommets_adj.at(a)<<std::endl;
+            }
+            std::cout<<std::endl;*/
+
             for(uint i=0;i<sommets_adj.size();i++)
             {
                 sommets_cut.push_back(Cout_coupe_pond(*sommetsDestination,sommets_adj[i],*g));
             }
+            /*std::cout<<"cut :"<<std::endl;
+            for(uint a = 0; a<sommets_cut.size(); a++){
+            	std::cout<<sommets_cut.at(a)<<std::endl;
+            }
+            std::cout<<std::endl;*/
             sommetsDestination->push_back(sommets_adj[recherche_val2(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
+            //std::cout<<"Sommet deplacé : "<<sommets_adj[recherche_val2(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]<<std::endl;
             poids+=(*g)[sommets_adj[recherche_val2(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]]._weight;
             suprim_val(*sommetsSource, sommets_adj[recherche_val2(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
             suprim_val(sommets_adj, sommets_adj[recherche_val2(sommets_cut,*min_element(sommets_cut.begin(),sommets_cut.end()))]);
@@ -176,10 +205,17 @@ void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource,
             sommets_cut.clear();
 
         }
-    }
 
-    edge_t e1;
-    // bool found;
+        /*for(uint i =0; i<sommetsSource->size();i++){
+        	std::cout<<sommetsSource->at(i)<<",";
+        }
+        std::cout<<std::endl;
+        for(uint i =0; i<sommetsDestination->size();i++){
+        	std::cout<<sommetsDestination->at(i)<<",";
+        }
+        std::cout<<std::endl;*/
+
+    }
 
     for (uint i=0; i<sommetsSource->size();i++)
     {
@@ -189,6 +225,8 @@ void gggp_pond(UnorientedGraph *g, Entiers *sommetsSource,
         }
     }
     sort(sommetsDestination->begin(), sommetsDestination->end());
+
+    //std::cout<<"fin du gggp_pond"<<std::endl;
 }
 
 void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
@@ -213,14 +251,15 @@ void Iter_2l(EntiersEntiers &part, int nbr_parties, UnorientedGraph *g,
 
         for(int i = 0; i<floor(log(nbr_parties)/log(2)); i++)
         {
-            std::cout<<"Et un tours de plus !!!! "<<std::endl;
+            //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;
+                //std::clog<<"sortie du gggp_pond"<<std::endl;
                 part.push_back(Q);
             }
+            //std::cout<<"\n"<<std::endl;
 
         }
     }
@@ -233,7 +272,9 @@ void bissectionRec(UnorientedGraph *g, EntiersEntiers &Partition,
     {
         //std::cout<<"C'est de la forme 2l : "<<nbr_parties<<std::endl;
         Iter_2l(Partition,nbr_parties,g,nom);
-    } else {
+    }
+    else
+    {
         int puissance_2=0;
 
         Entiers tailles;
@@ -241,7 +282,6 @@ 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);
 
         for(unsigned int i = 0; i< Partition.size() -1 ; i++)
@@ -252,17 +292,7 @@ void bissectionRec(UnorientedGraph *g, EntiersEntiers &Partition,
                     Partition.at(i)->swap(**it1);
             }
         }
-        /*std::cout<<"****"<<std::endl;
-          for(int k=0; k<Partition.size(); k++)
-          {
-          for(int j=0; j<Partition[k]->size(); j++)
-          {
-          std::cout<<Partition[k]->at(j)<<std::endl;
-          }
-          std::cout<<"\n"<<std::endl;
-          }
-          std::cout<<"****"<<std::endl;
-          std::cout<<"Et on termine les dernières bissections !!!! "<<std::endl;*/
+
         for(int j = 0; j<nbr_parties-pow(2,puissance_2-1);j++)
         {
             Entiers *Q = new Entiers();
@@ -271,9 +301,15 @@ void bissectionRec(UnorientedGraph *g, EntiersEntiers &Partition,
             else
                 gggp_pond(g,Partition.at(j),Q,Partition);
             Partition.push_back(Q);
-            //Q.clear();
         }
     }
+    std::cout<<"Partition avant affinage "<<std::endl;
+    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::cout<<"\n"<<std::endl;
+    }
 }
 
 /**
@@ -313,7 +349,6 @@ void Pseudo_random_partitioning(UnorientedGraph *g, EntiersEntiers &Partition,
             part->push_back(vertex);// ajout du sommet tiré
             suprim_val(*Partition.at(0),vertex);//suppression du sommet dans la premiere partie
 
-
         }
     }
     /*
@@ -377,10 +412,49 @@ void Pseudo_random_partitioning(UnorientedGraph *g, EntiersEntiers &Partition,
     }
 }
 
+EntiersEntiers Random_partitioning(UnorientedGraph *g,
+                                uint nbr_parties)
+{
+	EntiersEntiers Partition;
+	Entiers random_order; //gestion d'un tableau contenant tout les sommets et ranger de façon aléatoire
+
+	for (uint i=0 ; i<num_vertices(*g) ; i++)
+		random_order.push_back(i);
+	for (uint j=0 ; j<num_vertices(*g)-1 ; j++) {
+		int rand_pos = rand()%(num_vertices(*g)-j)+j;
+		int tmp      = random_order.at(j);
+		random_order.at(j) = random_order.at(rand_pos);
+		random_order.at(rand_pos) = tmp;
+	}
+
+	uint size = num_vertices(*g)/nbr_parties;
+	for(uint j = 0 ; j < nbr_parties-1 ; j++){
+		Entiers *part = new Entiers();
+		for(uint i = j*size; i<(j+1)*size; i++){
+			part->push_back(random_order.at(i));
+		}
+		Partition.push_back(part);
+	}
+
+	Entiers *part = new Entiers();
+	for(uint i = (nbr_parties-1)*size; i < random_order.size(); i++){
+		part->push_back(random_order.at(i));
+	}
+	Partition.push_back(part);
+
+	for(uint i = 0 ; i < Partition.size() ; i++){
+		sort(Partition.at(i)->begin(),Partition.at(i)->end());
+	}
+
+	return Partition;
+}
+
 OrientedGraphs Multiniveau(uint niveau_contraction,
                            UnorientedGraph *g,
+                           UnorientedGraph *graph_origin,
                            OrientedGraph *go,
                            int nbr_parties,
+                           std::string contraction,
                            std::string type_methode,
                            std::string choix_affinage,
                            std::string type_cut,
@@ -397,56 +471,109 @@ OrientedGraphs Multiniveau(uint niveau_contraction,
     uint cpt =0;
     while(num_vertices(*baseg.at(cpt))>niveau_contraction)
     {
-        contraction_HEM(baseg.at(cpt),baseg,liste_corr);
+    	if(contraction == "HEM")
+    		contraction_HEM(baseg.at(cpt),baseg,liste_corr);
+    	else
+    		contraction_Random_Maching(baseg.at(cpt),baseg,liste_corr);
         cpt++;
+        std::cout<<"passage"<<std::endl;
     }
 
-    for(uint i = 0;i < num_vertices(*baseg.at(baseg.size() - 1)); i++)
-    {
-        part->push_back(i);
+    std::cout<<"Graphe contracté : "<<std::endl;
+    for (uint i = 0; i< baseg.size(); i++) {
+        tie(vertexIt, vertexEnd) = vertices(*baseg[i]);
+        for (; vertexIt != vertexEnd; ++vertexIt) {
+            std::cout << (*baseg[i])[*vertexIt]._index
+                      << " est connecté avec ";
+            tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt,
+            		*baseg[i]);
+            for (; neighbourIt != neighbourEnd; ++neighbourIt)
+                std::cout << (*baseg[i])[*neighbourIt]._index << " ";
+            std::cout << " et son poids est de "
+                      << (*baseg[i])[*vertexIt]._weight<<std::endl;
+        }
+        std::cout << std::endl;
     }
-    Partition.push_back(part);
 
-    bissectionRec(baseg.at(baseg.size()-1),Partition,nbr_parties,type_methode);
+    std::cout<<"Partitionnement "<<std::endl;
+    if(type_methode == "gggp_pond" || type_methode == "gggp"){
+        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);
+    }
+    else
+    	Partition = Random_partitioning(baseg.at(baseg.size()-1),nbr_parties);
+    std::cout<<std::endl;
 
-    std::clog<<"Partition : "<<std::endl;
-    for(uint i = 0; i< Partition.size() ; i++)
-    {
-    for(uint j = 0 ; j<Partition.at(i)->size() ; j++)
-    {
-    std::cout<<(*baseg.at(baseg.size()-1))[Partition.at(i)->at(j)]._index<<std::endl;
+    ListEntiersEntiers::iterator lit(liste_corr.end());
+    bool proj;
+    uint taille_list = liste_corr.size();
+    if(liste_corr.size()==0){
+    	taille_list = 1;
+    	proj = true;
     }
-    std::cout<<"\n"<<std::endl;
+    else{
+    	lit--;
+    	proj = false;
     }
 
-    ListEntiersEntiers::iterator lit(liste_corr.end());
-    lit--;
-    for(uint y =0; y<liste_corr.size();y++){
-        projection(Partition,lit);
-        double cut = Cut_cluster(Partition,*baseg.at(baseg.size()-2-y),type_cut);
-        std::cout<<"Cout de coupe avant affinage : "<<cut<<std::endl;
-
-        if(choix_affinage=="charge")
-            Affinage_equilibrage_charge(baseg.at(baseg.size()-2-y),Partition);
-        else
-            Affinage_recherche_locale(baseg.at(baseg.size()-2-y),Partition,cut,type_cut);
+    for(uint y =0; y<taille_list;y++){
+    	if(proj != true){
+    		std::cout<<"Projection "<<std::endl;
+    		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<<"Affinage "<<std::endl;
+    		if(choix_affinage=="charge")
+    			Affinage_equilibrage_charge(baseg.at(baseg.size()-2-y),Partition);
+    		else
+    			Affinage_recherche_locale(baseg.at(baseg.size()-2-y),Partition,cut,type_cut);
+
+    		lit--;
+    	}
+    	else{
+    		std::cout<<"Pas de projection "<<std::endl;
+    		std::cout<<std::endl;
+
+    		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;
+    			if(choix_affinage=="charge")
+    				Affinage_equilibrage_charge(graph_origin,Partition);
+    			else{
+    				Affinage_recherche_locale(graph_origin,Partition,cut,type_cut);
+    				std::cout<<"Cout de coupe après affinage : "<<cut<<std::endl;
+    			}
+    		}
+    		else
+    			std::cout<<"Pas d'affinage "<<std::endl;
+    	}
 
-        std::cout<<"Cout de coupe après affinage : "<<cut<<std::endl;
-        lit--;
     }
 
     OrientedGraphs Graphes = Graph_Partition(Partition, go, g, outputedgeslist,
                                              inputedgelist, connections);
 
-    for(int k=0; k<Partition.size(); k++)
+    std::cout<<std::endl;
+    std::cout<<"Résultat de la partition "<<std::endl;
+    for(uint k=0; k<Partition.size(); k++)
     {
-    	for(int j=0; j<Partition[k]->size(); j++)
+    	for(uint j=0; j<Partition.at(k)->size(); j++)
     	{
-    		std::cout<<Partition[k]->at(j)<<std::endl;
+    		std::cout<<Partition.at(k)->at(j)<<" ";
     	}
     	std::cout<<"\n"<<std::endl;
     }
-    std::cout<<"****"<<std::endl;
+
+	double cut = Cut_cluster(Partition,*graph_origin,"cut");
+	std::cout<<"Cout de coupe engendré par le partitionnement: "<<cut<<std::endl;
+
 
     for(EntiersEntiers::iterator it = Partition.begin(); it != Partition.end(); it++)
     {

+ 5 - 1
src/tests/boost_graph/partitioning/gggp.hpp

@@ -46,8 +46,12 @@ void bissectionRec(UnorientedGraph *g, EntiersEntiers &Partition,
 void Pseudo_random_partitioning(UnorientedGraph *g, EntiersEntiers &Partition,
                                 uint nbr_parties);
 
-OrientedGraphs Multiniveau(uint niveau_contraction, UnorientedGraph *g,
+EntiersEntiers Random_partitioning(UnorientedGraph *g,
+                                uint nbr_parties);
+
+OrientedGraphs Multiniveau(uint niveau_contraction, UnorientedGraph *g, UnorientedGraph *graph_origin,
                            OrientedGraph *go, int nbr_parties,
+                           std::string contraction,
                            std::string type_methode,
                            std::string choix_affinage,
                            std::string type_cut,

+ 251 - 21
src/tests/boost_graph/partitioning/graph_build.cpp

@@ -45,6 +45,35 @@ void build_graph(UnorientedGraph& ug, OrientedGraph& 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);
@@ -63,8 +92,55 @@ void build_graph(UnorientedGraph& ug, OrientedGraph& 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(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[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);
@@ -74,16 +150,56 @@ void build_graph(UnorientedGraph& ug, OrientedGraph& og)
     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[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 v11 = boost::add_vertex(ug);
-    vertex_t v21 = boost::add_vertex(ug);
-    vertex_t v31 = 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);
@@ -91,36 +207,150 @@ void build_graph(UnorientedGraph& ug, OrientedGraph& og)
     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, v11, EdgeProperties(1.), ug);
-    boost::add_edge(v01, v21, EdgeProperties(1.), ug);
-    boost::add_edge(v01, v31, EdgeProperties(1.), ug);
-    boost::add_edge(v11, v21, EdgeProperties(1.), ug);
-    boost::add_edge(v11, v41, EdgeProperties(1.), ug);
-    boost::add_edge(v11, v51, EdgeProperties(1.), ug);
-    boost::add_edge(v11, v61, EdgeProperties(1.), ug);
-    boost::add_edge(v21, v61, EdgeProperties(1.), ug);
-    boost::add_edge(v21, v31, EdgeProperties(1.), ug);
-    boost::add_edge(v31, v91, EdgeProperties(1.), ug);
-    boost::add_edge(v31, v101, EdgeProperties(1.), 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(v121, v131, 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[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[v11] = VertexProperties(10, 2, NORMAL_PIXEL);
-    ug[v21] = VertexProperties(20, 2, NORMAL_PIXEL);
-    ug[v31] = VertexProperties(30, 2, 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[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);
 
 }
 

+ 19 - 179
src/tests/boost_graph/partitioning/main.cpp

@@ -47,122 +47,33 @@ int main()
 
     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);
 
-    int nbr_parties = 3;
-    Edges edge_partie;
-    OutputEdgeList outputedgeslist(nbr_parties);
-    InputEdgeList inputedgelist;
-    Connections connections;
-
-    /*EntiersEntiers Partition;
-      Entiers *part = new Entiers();
-      Base_Graph baseg;
-      baseg.push_back(g);
-      ListEntiersEntiers liste_corr;
-      uint cpt=0;
-      while(num_vertices(*baseg.at(cpt))>4)
-      {
-      contraction_HEM(baseg.at(cpt),baseg,liste_corr);
-      cpt++;
-      }
-
-      edge_t e1;
-      bool found;
-      for(uint i=0;i<baseg.size();i++){
-      tie(vertexIt, vertexEnd) = vertices((*baseg.at(i)));
-      for (; vertexIt != vertexEnd; ++vertexIt)
-      {
-      std::cout << *vertexIt << " est connecté avec ";
-      tie(neighbourIt, neighbourEnd) = adjacent_vertices(*vertexIt, (*baseg.at(i)));
-      for (; neighbourIt != neighbourEnd; ++neighbourIt){
-      std::cout << *neighbourIt << " ";
-      tie(e1,found)=edge(vertex(*vertexIt,*baseg.at(i)),vertex(*neighbourIt,*baseg.at(i)),*baseg.at(i));
-      std::cout << "poids arc : "<<(*baseg.at(i))[e1]._weight<<"\n";
-      }
-      std::cout<<" et son poids est de "<< (*baseg.at(i))[*vertexIt]._weight<<std::endl;
-      }
-      std::cout<<"\n"<<std::endl;
-      }
-
-
-      for(int i =0;i<num_vertices(*baseg.at(baseg.size()-1));i++)
-      {
-      part->push_back(i);
-      }
-      Partition.push_back(part);
+    delete gop;
 
-      bissectionRec(baseg.at(baseg.size()-1),Partition,3,"gggp_pond");
-      //Pseudo_random_partitioning(g,Partition,3);
-      std::cout<<"Nombre de parties : "<<Partition.size()<<std::endl;
+    int nbr_parties = 38;
 
-      std::clog<<"Resultat de la partition : "<<std::endl;
-      std::cout<<"****"<<std::endl;
-      for(uint i = 0; i< Partition.size() ; i++)
-      {
-      for(uint j = 0 ; j<Partition.at(i)->size() ; j++)
-      {
-      std::cout<<(*baseg.at(baseg.size()-1))[Partition.at(i)->at(j)]._index<<std::endl;
-      }
-      std::cout<<"\n"<<std::endl;
-      }
-      std::cout<<"****"<<std::endl;
+    /*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;
+    }
 
-      ListEntiersEntiers::iterator lit(liste_corr.end());
-      lit--;
-      for(uint y =0; y<liste_corr.size();y++){
-      projection(Partition,lit);
-
-      std::clog<<"liste de correspondance : "<<std::endl;
-      for(uint i = 0; i < (*lit)->size(); i++)
-      {
-      for(uint j = 0; j < (*lit)->at(i)->size();j++){
-      std::cout<<(*lit)->at(i)->at(j)<<std::endl;;
-      }
-      std::cout<<"\n"<<std::endl;
-      }
-
-      std::clog<<"Resultat projection : "<<std::endl;
-      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<<"\n"<<std::endl;
-      }
-
-      double cut = Cut_cluster(Partition,*baseg.at(baseg.size()-2-y),"norm");
-
-      std::cout<<"Cout de coupe avant affinage : "<<cut<<std::endl;
-
-      Affinage_recherche_locale(baseg.at(baseg.size()-2-y),Partition,cut,"norm");
-      //Affinage_equilibrage_charge(baseg.at(baseg.size()-2-y),Partition);
-      std::cout<<"Cout de coupe après affinage : "<<cut<<std::endl;
-      std::cout<<"\n"<<std::endl;
-      double tmp = Cut_cluster(Partition,*baseg.at(baseg.size()-2-y),"norm");
-      std::cout<<"verification cout de coupe après affinage : "<<tmp<<std::endl;
-      std::cout<<"\n"<<std::endl;
-      std::clog<<"Partition après affinage : "<<std::endl;
-      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<<"\n"<<std::endl;
-      }
-
-      lit--;
-      }
-      std::cout<<"mathieu va me buter ! et en plus c'est walker !!!"<<std::endl;
-      std::cout<<"\n"<<std::endl;
+    std::cout<<Partition.size()<<std::endl;*/
 
-      OrientedGraphs Graphes = Graph_Partition(Partition,go,g,outputedgeslist,inputedgelist,connections);*/
+    Edges edge_partie;
+    OutputEdgeList outputedgeslist(nbr_parties);
+    InputEdgeList inputedgelist;
+    Connections connections;
 
-    OrientedGraphs graphs = Multiniveau(4, g, go, nbr_parties, "gggp_pond",
+    OrientedGraphs graphs = Multiniveau(38, g, graph_origin, go, nbr_parties,"HEM", "gggp_pond",
                                         "cut_norm", "norm", edge_partie ,
                                         outputedgeslist, inputedgelist,
                                         connections);
@@ -211,79 +122,8 @@ int main()
                   << std::endl;
     }
 
-    /*for(EntiersEntiers::iterator it = Partition.begin(); it != Partition.end(); it++)
-      {
-      delete *it;
-      *it = NULL;
-      }
-
-      for(ListEntiersEntiers::iterator it = liste_corr.begin(); it != liste_corr.end(); it++)
-      {
-      for(EntiersEntiers::iterator it1 = (*it)->begin(); it1 != (*it)->end(); it1++)
-      {
-      delete *it1;
-      *it1 = NULL;
-      }
-      delete *it;
-      *it = NULL;
-      }
-
-      for(Base_Graph::iterator it = baseg.begin(); it != baseg.end(); it++)
-      {
-      delete *it;
-      *it = NULL;
-      }*/
-
-    // for(OrientedGraphs::iterator it = Graphes.begin(); it != Graphes.end();
-    //     it++) {
-    //     delete *it;
-    //     *it = NULL;
-    // }
+	delete graph_origin;
 
     std::cout << "Duration : " << t.elapsed() << " seconds" << std::endl;
 
-    //EntiersEntiersEntiers Stock_Partition;
-    /*for(int i=0;i<11;i++){
-      g1=g;
-      Partition1=Partition;
-      bissectionRec(g1,Partition1,4,"gggp");
-      Stock_Partition.push_back(Partition1);
-      Cut.push_back(Cut_cluster(Partition1,g));
-      Partition1.clear();
-      g1.clear();
-      }
-
-      for(int i =0;i<Cut.size();i++){
-      std::cout<<Cut[i]<<std::endl;
-      }
-      std::cout<<"\n"<<std::endl;
-      std::cout<<recherche_val_double(Cut,*min_element(Cut.begin(),Cut.end()))<<std::endl;
-      std::cout<<"\n"<<std::endl;
-      EntiersEntiers tmp = Stock_Partition[recherche_val_double(Cut,*min_element(Cut.begin(),Cut.end()))];
-      for(int i =0; i<tmp.size();i++){
-      for(int j=0; j<tmp[i].size();j++){
-      std::cout<<tmp[i][j]<<std::endl;
-      }
-      std::cout<<"\n"<<std::endl;
-      }*/
-
-    /*EntiersEntiers liste_corr;
-    //double cut = Cut_cluster(Partition,g);
-    Base_Graph baseg;
-    baseg.push_back(g);
-
-
-
-
-    std::cout<<"LIste des noeuds fusionés : "<<std::endl;
-    for(uint i = 0; i< liste_corr.size() ; i++)
-    {
-    for(uint j = 0 ; j<liste_corr.at(i).size() ; j++)
-    {
-    std::cout<<liste_corr[i][j]<<std::endl;
-    }
-    std::cout<<"\n"<<std::endl;
-    }*/
-
-
 }

+ 161 - 9
src/tests/boost_graph/partitioning/utils.cpp

@@ -422,7 +422,7 @@ void Affinage_recherche_locale(UnorientedGraph *g, EntiersEntiers &Partition, do
 
     Entiers random_orders(num_vertices(*g)); //gestion d'un tableau contenant tout les sommets et ranger de façon aléatoire
 
-    for (uint i=0 ; i<random_orders.size() ; i++)
+    for (uint i=0 ; i<num_vertices(*g) ; i++)
         random_orders.at(i)=i;
 
     for (uint j=0 ; j<num_vertices(*g)-1 ; j++) {
@@ -433,11 +433,12 @@ void Affinage_recherche_locale(UnorientedGraph *g, EntiersEntiers &Partition, do
     }
     uint size = random_orders.size();
 
-    if(random_orders.size()>500)
+    if(num_vertices(*g)>500)
         size=500;
 
     std::vector<std::vector<double> > tabe_cut;
 
+    //std::cout<<"Passage : "<<Partition.size()<<std::endl;
     for(uint k = 0; k < Partition.size();k++){
         std::vector<double> tmp;
         double vol = 0.;
@@ -447,21 +448,20 @@ void Affinage_recherche_locale(UnorientedGraph *g, EntiersEntiers &Partition, do
         tabe_cut.push_back(tmp);
     }
 
-
     for(uint i = 0; i < size; i++){
         if(random_orders.at(i)!=-1){
             int vertex = random_orders.at(i);
-
+            //std::cout<<vertex<<std::endl;
             int comm = In_community_dichotomie(Partition, vertex);
             Entiers community = Neigh_community(g,Partition,vertex,comm);
             std::vector<double> tmp_cut;
 
             if(community.size()!=0 && Partition.at(comm)->size()!=1){
                 tmp_cut = modif_cut_tmp(g,Partition,tabe_cut,vertex,comm,community,cut,name);
-                for(uint z = 0; z<tmp_cut.size(); z++){
+                /*for(uint z = 0; z<tmp_cut.size(); z++){
                     std::cout<<tmp_cut.at(z)<<std::endl;
                 }
-                std::cout<<"\n"<<std::endl;
+                std::cout<<"\n"<<std::endl;*/
                 double cut_min = *min_element(tmp_cut.begin(),tmp_cut.end());
                 std::cout<<"cout de coupe minimum de la liste : "<<cut_min<<std::endl;
                 if(cut_min<cut){
@@ -521,7 +521,7 @@ double Modif_Cut_one_cluster(Entiers &cluster, UnorientedGraph &g, double &vol)
 std::vector<double> modif_cut_tmp(UnorientedGraph *g, EntiersEntiers &Partition, std::vector<std::vector<double> > tabe_cut, int vertexs, int comm_in, Entiers community, double cut,std::string name){
 	edge_t e1;
 	bool found;
-	std::cout<<"le sommet tiré est : "<<vertexs<<std::endl;
+	//std::cout<<"le sommet tiré est : "<<vertexs<<std::endl;
 
 	if(name!="norm")
 	{
@@ -814,6 +814,158 @@ void contraction_HEM(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &
 	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
 }
 
+void contraction_Random_Maching(UnorientedGraph *g, Base_Graph &baseg, ListEntiersEntiers &liste_corr){
+	UnorientedGraph *gtmp = new UnorientedGraph();
+	*gtmp=*g;
+	Entiers Random_list_vertices; // Initialisation du tableau de sommets rangés aléatoirements
+	EntiersEntiers *tableau_de_correspondance = new EntiersEntiers();
+	edge_t e1,e2; // Iterateurs sur les arcs
+	bool found;
+	uint nbr_vertex = num_vertices(*gtmp);
+	Entiers sommets_a_detruire; // Initialisation d'un tableau pret à recevoir les "sommets à détruire"
+	/*
+	 * Création d'un vecteur contenant l'ensemble des sommets du graphe. Ces sommets sont rangés
+	 * aléatoirement afin de simuler un tirage aléatoire
+	 */
+	for (uint i=0 ; i<nbr_vertex ; i++)
+		Random_list_vertices.push_back(i);
+	for (uint j=0 ; j<nbr_vertex-1 ; j++) {
+		int rand_pos = rand()%(nbr_vertex-j)+j;
+		int tmp      = Random_list_vertices[j];
+		Random_list_vertices[j] = Random_list_vertices[rand_pos];
+		Random_list_vertices[rand_pos] = tmp;
+	}
+
+	/*
+	 * Pour chaque sommet non verrouiller faire ....
+	 */
+	for(uint i=0; i<nbr_vertex; i++){
+		int vertexs = Random_list_vertices[i];
+		if(vertexs!=-1){
+			Entiers liste_voisin = Liste_adjacence(*gtmp,vertexs,Random_list_vertices); // Recherche des sommets adjacents au sommets  tiré
+			if(liste_voisin.size()!=0){
+				/*
+				 * S'il en existe au mois un sommet adjacent au sommet tiré qui n'est pas verrouillé, on
+				 * choisi celui dont l'arc les reliants est le plus fort. Dans le cas où les arcs ont tous
+				 * le même poids, on selectionne le sommet d'identifiant le plus petit
+				 */
+				int tmp;
+				if(liste_voisin.size()==1)
+					tmp = 0;
+				else
+					tmp = rand_fini(0,liste_voisin.size()-1);
+
+				int best_vertexs = liste_voisin.at(tmp);
+
+				Entiers * couple = new Entiers(); // Initialisation du vecteur contenant le couple de sommet fusionné
+				int vertex_delete = std::max(vertexs, best_vertexs); // Sommet d'indentifiant le plus grand (qui sera détruit)
+				//std::cout<<"sommet détruit : "<<vertex_delete<<std::endl;
+				int vertex_save = std::min(vertexs,best_vertexs); // Sommet d'identifiant le plus petit (qui sera conservé)
+				//std::cout<<"sommet sauvé : "<<vertex_save<<std::endl;
+
+				sommets_a_detruire.push_back(vertex_delete); // On ajoute le sommet détruit au tableau des sommets à détruire
+				/*
+				 * On ajoute au tableau "couple" le couple de sommet à fusionner
+				 */
+				couple->push_back(vertex_save);
+				couple->push_back(vertex_delete);
+				tableau_de_correspondance->push_back(couple); // Ajout du "couple" à la liste de correspondance
+
+				remove_edge(vertex_save,vertex_delete,*gtmp); // Suppression de l'arc reliant le couple de sommets
+
+				Entiers neigh_vertex_save; // Initialisation du vecteur contenant les somemts adjacents au "sommet sauvegardé"
+				Entiers neigh_vertex_delete; // Initialisation du vecteur contenant les somemts adjacents au "sommet à détruire"
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_save,*gtmp);
+
+				/*
+				 * Remplissage de ces deux tableaux à l'aide de la fonction adjacent_vertices de boost graph
+				 * [La création de ces tableaux est nécéssaire du fait que certains arcs sont détruit au cours
+				 * du processus]
+				 */
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_save.push_back(*neighbourIt);
+				}
+
+				tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertex_delete,*gtmp);
+				for (; neighbourIt != neighbourEnd; ++neighbourIt){
+					neigh_vertex_delete.push_back(*neighbourIt);
+				}
+
+				/*
+				 * Recherche de sommets communs entre le "sommet sauvegardé" et le "sommet à détruire"
+				 * S'il existe un tel sommet "v" alors on ajoute le poids de l'arcs (vertex_delet,v)
+				 * à celui de l'arcs (vertex_save,v) et on détruit l'arcs reliant "v" au "sommet à détruire"
+				 */
+				for(uint j=0;j<neigh_vertex_delete.size();j++){
+					if(In_tab(neigh_vertex_save,neigh_vertex_delete[j])==1){
+						tie(e2,found)=edge(vertex(vertex_save,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						(*gtmp)[e2]._weight+=(*gtmp)[e1]._weight;
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+					else
+					{
+						tie(e1,found)=edge(vertex(vertex_delete,*gtmp),vertex(neigh_vertex_delete[j],*gtmp),*gtmp);
+						add_edge(vertex_save,neigh_vertex_delete[j],EdgeProperties((*gtmp)[e1]._weight),*gtmp);
+						remove_edge(vertex_delete,neigh_vertex_delete[j],*gtmp);
+					}
+				}
+
+				(*gtmp)[vertex_save]._weight+=(*gtmp)[vertex_delete]._weight; // ajout du poids du sommet détruit au sommet conservé
+				/*
+				 * Vérouillage du "sommet sauvegardé" et du "sommet à détruire"
+				 */
+				Random_list_vertices[i]=-1;
+				Random_list_vertices[recherche_val(Random_list_vertices,best_vertexs)]=-1;
+			}
+			else{
+				/*
+				 * Et si le sommet tiré ne possède pas de sommet adjacent non verrouillé
+				 * alors on l'ajoute à la liste de correspondance des sommets et on
+				 * le verrouille
+				 */
+				Entiers *couple = new Entiers();
+				couple->push_back(Random_list_vertices.at(i));
+				tableau_de_correspondance->push_back(couple);
+				Random_list_vertices[i]=-1;
+			}
+		}
+	}
+
+	std::sort(sommets_a_detruire.begin(), sommets_a_detruire.end()); // Trie dans l'ordre croissant des "sommets à détruire"
+	//std::cout<<"\n"<<std::endl;
+	/*
+	 * Suppression des sommets de la liste "sommets à détruire". Cette suppression est
+	 * effectuée dans l'ordre décroissant afin à maintenir à jour la renumérotation
+	 * des sommets
+	 */
+	for(int j=(sommets_a_detruire.size()-1);j>-1;j--){
+		//std::cout<<"Noeuds a supprimer : "<<sommets_a_detruire.at(j)<<std::endl;
+		remove_vertex(sommets_a_detruire[j],*gtmp);
+	}
+
+	/**std::clog<<"Affichage avant tri "<<std::endl;
+	for(uint k = 0;k<tableau_de_correspondance->size();k++){
+		for(uint v = 0; v<tableau_de_correspondance->at(k)->size();v++){
+			std::cout<<tableau_de_correspondance->at(k)->at(v)<<" ";
+		}
+		std::cout<<"\n"<<std::endl;
+	}*/
+	std::sort(tableau_de_correspondance->begin(),tableau_de_correspondance->end(),myobject); // Trie dans l'ordre croissant des couples de sommets de la liste de correspondance
+
+	std::clog<<"Tableau de correspondance "<<std::endl;
+	for(uint k = 0;k<tableau_de_correspondance->size();k++){
+		for(uint v = 0; v<tableau_de_correspondance->at(k)->size();v++){
+			std::cout<<tableau_de_correspondance->at(k)->at(v)<<" ";
+		}
+		std::cout<<"\n"<<std::endl;
+	}
+
+	liste_corr.push_back(tableau_de_correspondance);
+	std::cout<<"\n"<<std::endl;
+	baseg.push_back(gtmp); // Ajout du graphe modifié à la "base des graphe"
+}
+
 Entiers Liste_adjacence(UnorientedGraph &g, int vertexs,const Entiers &random_vertices){ // a revoir !!!!
 	Entiers liste_voisin;
 	tie(neighbourIt, neighbourEnd) = adjacent_vertices(vertexs, g);
@@ -915,9 +1067,9 @@ bool In_tab_dichotomie(const Entiers &tab, int val)
 }
 
 
-void Liste_Voisin(Entiers &P,Entiers &tab,const UnorientedGraph &g)
+void Liste_Voisin(const Entiers &P,Entiers &tab,const UnorientedGraph &g)
 {
-	tie(neighbourIt, neighbourEnd) = adjacent_vertices(P[P.size()-1], g);
+	tie(neighbourIt, neighbourEnd) = adjacent_vertices(P.at(P.size()-1), g);
 	for (; neighbourIt != neighbourEnd; ++neighbourIt)
 	{
 		if((In_tab(tab,*neighbourIt) == false ) && (In_tab(P,*neighbourIt) == false ))

+ 3 - 1
src/tests/boost_graph/partitioning/utils.hpp

@@ -75,6 +75,8 @@ void projection(EntiersEntiers &Partition,ListEntiersEntiers::iterator lit);
 
 void contraction_HEM(UnorientedGraph *g, Base_Graph &baseg,
                      ListEntiersEntiers &liste_corr);
+void contraction_Random_Maching(UnorientedGraph *g, Base_Graph &baseg,
+								ListEntiersEntiers &liste_corr);
 
 Entiers Liste_adjacence(UnorientedGraph &g, int vertexs,
                         const Entiers &random_vertices);
@@ -92,7 +94,7 @@ double Cut_cluster(const EntiersEntiers &tab_cluster,UnorientedGraph &g,
 void Modif_fonction_Gain_Cut(EntiersEntiers &Partition,UnorientedGraph *g,
                              int community_out,int community_in,int val,
                              double &cut);
-void Liste_Voisin(Entiers &P,Entiers &tab,const UnorientedGraph &g);
+void Liste_Voisin(const Entiers &P,Entiers &tab,const UnorientedGraph &g);
 int Cout_coupe(Entiers P,int val, UnorientedGraph &g);
 double Cout_coupe_pond(Entiers P,int val, UnorientedGraph &g);
 int In_community_dichotomie(const EntiersEntiers &part, int val);