/usr/include/dolfin/graph/BoostGraphInterface.h is in libdolfin1.0-dev 1.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | // Copyright (C) 2010 Garth N. Wells
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// First added: 2010-11-24
// Last changed:
#ifndef __DOLFIN_BOOST_GRAPH_INTERFACE_H
#define __DOLFIN_BOOST_GRAPH_INTERFACE_H
#include <iostream>
#include <boost/graph/sequential_vertex_coloring.hpp>
#include <dolfin/common/Array.h>
#include <dolfin/common/types.h>
#include <dolfin/graph/Graph.h>
namespace dolfin
{
template<typename T> class Array;
class Mesh;
/// This class colors a graph using the Boost Graph Library.
class BoostGraphInterface
{
public:
/// Compute vertex colors
static uint compute_local_vertex_coloring(const Graph& graph, Array<uint>& colors);
/// Compute vertex colors
template<typename T>
static uint compute_local_vertex_coloring(const T& graph, Array<uint>& colors)
{
// Number of vertices in graph
const uint num_vertices = boost::num_vertices(graph);
dolfin_assert(num_vertices == colors.size());
typedef typename boost::graph_traits<T>::vertex_descriptor vert_descriptor;
typedef typename boost::graph_traits<T>::vertex_iterator vert_iterator;
typedef typename boost::graph_traits<T>::vertices_size_type vert_size_type;
typedef typename boost::property_map<T, boost::vertex_index_t>::const_type vert_index_map;
// Create vector to hold colors
std::vector<vert_size_type> color_vec(num_vertices);
// Color vertices
std::cout << "Start Boost coloring." << std::endl;
boost::iterator_property_map<vert_size_type*, vert_index_map> color(&color_vec.front(), get(boost::vertex_index, graph));
const vert_size_type num_colors = sequential_vertex_coloring(graph, color);
std::cout << "Boost coloring finished." << std::endl;
// Copy result into Array
dolfin_assert(colors.size() == color_vec.size());
for (uint i = 0; i < num_vertices; ++i)
colors[i] = color_vec[i];
std::cout << "Number of colors: " << num_colors << std::endl;
return num_colors;
}
};
}
#endif
|