|
Boost Users : |
Subject: [Boost-users] [graph] std::priority_queue of vertex_descriptors with extended comparison object will not initialize
From: Christoph (c_p_at_[hidden])
Date: 2011-10-27 07:23:45
Hi List,
as the Subject states. I would like to initialize a std::priority_queue
with vertex_descriptors and a comparison object as a template parameter
but the compiler tells me:
...
/usr/include/c++/4.5/bits/stl_heap.h:303:4: error: invalid conversion
from âunsigned intâ to âvoid*â
/usr/include/c++/4.5/bits/stl_heap.h:303:4: error: initializing
argument 1 of âbool degree_compare::operator()(void* const&, void*
const&)â
...
if i try to initialize the queue and i just don't know why 'bool
degree_compare::operator()(void* const&, void* const&)' comes up.
Could you please help me to initialize my priority_queue?
best regards
Christoph
// begin code
#include <iostream>
#include <map>
#include <queue>
#include <boost/graph/adjacency_list.hpp>
#include <boost/smart_ptr.hpp>
typedef boost::adjacency_list_traits<boost::listS, boost::vecS,
boost::bidirectionalS>
link_adjacency_list_traits;
struct vertex_properties;
struct edge_properties;
struct graph_properties;
struct vertex_properties {
std::map <int, link_adjacency_list_traits::edge_descriptor >
used_colors;
// this one works fine, i can use a traits::edge_descriptor
};
struct edge_properties {
int color;
};
struct degree_compare;
typedef std::priority_queue <
link_adjacency_list_traits::vertex_descriptor,
std::vector <link_adjacency_list_traits::vertex_descriptor>,
degree_compare> VERTEX_DEGREE_PQ;
struct graph_properties {
int delta;
boost::shared_ptr <VERTEX_DEGREE_PQ> pq;
};
typedef boost::adjacency_list < boost::listS,
boost::listS,
boost::bidirectionalS,
vertex_properties,
edge_properties,
graph_properties>
link_graph;
class degree_compare {
private:
link_graph g;
public:
degree_compare(const link_graph &g): g(g) {std::cout << "Num Vertices:
" << num_vertices(g) << std::endl;}
bool operator()(const
boost::graph_traits<link_graph>::vertex_descriptor &a,
const boost::graph_traits<link_graph>::vertex_descriptor &b) {
return out_degree(a, g) < out_degree(b, g);
}
};
int main ()
{
link_graph g;
boost::graph_traits<link_graph>::vertex_descriptor a = add_vertex (g);
degree_compare dc(g); // init the comparison object
VERTEX_DEGREE_PQ pq(dc);// init the p_queue with comparison
// object fails
//pq.push(a);
//pq.top();
}
// end code
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net