Back to index

salome-med  6.5.0
RENUMBER_BOOSTRenumbering.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include <boost/config.hpp>
00021 #include <boost/graph/adjacency_list.hpp>
00022 #include <boost/graph/cuthill_mckee_ordering.hpp>
00023 #include <boost/graph/properties.hpp>
00024 #include <boost/graph/bandwidth.hpp>
00025 
00026 #include "RENUMBER_BOOSTRenumbering.hxx"
00027 
00028 void BOOSTRenumbering::renumber(const int* graph,const int* index_graph,int nb_cell,std::vector<int>& iperm,std::vector<int>& perm)
00029 {
00030   iperm.resize(nb_cell,0);
00031   perm.resize(nb_cell,0);
00032 
00033   typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, 
00034      boost::property<boost::vertex_color_t, boost::default_color_type,
00035        boost::property<boost::vertex_degree_t,int> > > Graph;
00036   typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
00037   typedef boost::graph_traits<Graph>::vertices_size_type size_type;
00038   Graph G(nb_cell);
00039   for (int i=0;i<nb_cell;++i)
00040     for (int j=index_graph[i]-1;j<index_graph[i+1]-1;++j)
00041       add_edge(i,graph[j]-1,G);
00042   boost::property_map<Graph, boost::vertex_index_t>::type
00043     index_map = boost::get(boost::vertex_index, G);
00044   boost::cuthill_mckee_ordering(G, iperm.rbegin(), boost::get(boost::vertex_color, G),
00045                            boost::make_degree_map(G));
00046   for (size_type c = 0; c != iperm.size(); ++c)
00047     perm[index_map[iperm[c]]] = c;
00048   for(int i=0;i<nb_cell;++i)
00049     {
00050       perm[i]+=1;
00051       iperm[i]+=1;
00052     }
00053 }