1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <boost/config.hpp>
21 #include <boost/graph/adjacency_list.hpp>
22 #include <boost/graph/cuthill_mckee_ordering.hpp>
23 #include <boost/graph/properties.hpp>
24 #include <boost/graph/bandwidth.hpp>
26 #include "RENUMBER_BOOSTRenumbering.hxx"
28 void BOOSTRenumbering::renumber(const int* graph,const int* index_graph,int nb_cell,std::vector<int>& iperm,std::vector<int>& perm)
30 iperm.resize(nb_cell,0);
31 perm.resize(nb_cell,0);
33 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS,
34 boost::property<boost::vertex_color_t, boost::default_color_type,
35 boost::property<boost::vertex_degree_t,int> > > Graph;
36 typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
37 typedef boost::graph_traits<Graph>::vertices_size_type size_type;
39 for (int i=0;i<nb_cell;++i)
40 for (int j=index_graph[i]-1;j<index_graph[i+1]-1;++j)
41 add_edge(i,graph[j]-1,G);
42 boost::property_map<Graph, boost::vertex_index_t>::type
43 index_map = boost::get(boost::vertex_index, G);
44 boost::cuthill_mckee_ordering(G, iperm.rbegin(), boost::get(boost::vertex_color, G),
45 boost::make_degree_map(G));
46 for (size_type c = 0; c != iperm.size(); ++c)
47 perm[index_map[iperm[c]]] = c;
48 for(int i=0;i<nb_cell;++i)