Because of compiler issues, and reasons too numerous to be listed here, for this problem I'm currently stuck using MSVC 7.1, with the Boost Graph Library 1_31. I'm having a syntax problem that I thought someone could help me with.
I'm trying to use the graph coloring algorithm by calling sequential_vertex_coloring. In version 1_31, the function signature look like the following:
template
typename graph_traits<VertexListGraph>::size_type
sequential_vertex_coloring(const VertexListGraph& G, OrderPA order,
ColorMap color) ;
I'm not entirely certain what the OrderPA is supposed to be. I could see in Boost version 1_33, there was a convenience function that automatically created the 'order' argument. So I tried using that, but I got the following error:
main.cpp(31) : error C2893: Failed to specialize function template 'graph_traits<VertexListGraph>::size_type boost::sequential_vertex_coloring(const VertexListGraph &,OrderPA,ColorMap)'
With the following template arguments:
'Graph'
'boost::iterator_property_map'
Can somene tell me what I'm missing or doing wrong? Much appreciated. I've enclosed the code below.
-----------------------------------------------------------
#include
#include
template
typename boost::property_traits<ColorMap>::value_type
sequential_vertex_coloring(const VertexListGraph& G, ColorMap color) {
typedef typename boost::graph_traits<VertexListGraph>::vertex_descriptor
vertex_descriptor;
typedef typename boost::graph_traits<VertexListGraph>::vertex_iterator
vertex_iterator;
std::pair v = vertices(G);
#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS
std::vector order(v.first, v.second);
#else
std::vector order;
order.reserve(std::distance(v.first, v.second));
while (v.first != v.second) order.push_back(*v.first++);
#endif
return boost::sequential_vertex_coloring
(G,
boost::make_iterator_property_map
(order.begin(), boost::identity_property_map(),
boost::graph_traits<VertexListGraph>::null_vertex()),
color);
}
typedef boost::adjacency_list Graph;
typedef boost::graph_traits<Graph>::vertex_descriptor vert_descriptor;
typedef boost::graph_traits<Graph>::vertex_iterator vert_iterator;
typedef boost::graph_traits<Graph>::vertices_size_type vert_size_type;
typedef boost::property_map::const_type vert_index_map;
int main(int argc, char **argv) {
Graph g(5);
boost::add_edge(0, 1, g);
boost::add_edge(0, 2, g);
boost::add_edge(1, 2, g);
std::vector color_vec(5);
boost::iterator_property_map
color(&color_vec.front(), get(boost::vertex_index, g));
vert_size_type num_colors = sequential_vertex_coloring (g, color);
return 0;
}
---------------------------------
Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now.