I've troube using the in_degree function in boost graph. It fails with the following crytic message :
..\boost_lib\boost_1_66_0\boost\graph\detail\adjacency_list.hpp|1673|error: no matching function for call to 'in_edge_list(Graph&, void*&)'|
Why is vb
of void*&
type? It is supposed to be a vertex_descriptor.
Here a small example reproducing my issue :
#include <string>
#include <iostream>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
//The typedef used
typedef boost::adjacency_list<
boost::setS, boost::setS, boost::directedS> graph;
typedef boost::graph_traits<graph>::vertex_descriptor Vertex;
int main()
{
graph g(1);
boost::graph_traits<graph>::vertex_iterator vb,ve;
boost::tie(vb,ve)=boost::vertices(g);
std::cout << boost::in_degree(*vb,g);
return 0;
}
Why is vb of void*& type? It is supposed to be a vertex_descriptor.
And why shouldn't that descriptor be of void*
type? That's exactly the type that it's defined to be.
error: no matching function for call to 'in_edge_list(Graph&, void*&)'
The problem is, there is no matching function call, because in_degree()
isn't supposed to work on your graph. You can see what your graph supports here: http://www.boost.org/doc/libs/1_66_0/libs/graph/doc/graph_concepts.html
As you can see in_degree()
requires the BidirectionalGraph
concept.
You could be satisfied knowing just the out-degree:
std::cout << boost::out_degree(*vb, g);
Or you can switch to a BidirectionalGraph model:
#include <iostream>
#include <string>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_traits.hpp>
typedef boost::adjacency_list<boost::setS, boost::setS, boost::bidirectionalS> graph;
typedef graph::vertex_descriptor Vertex;
int main() {
graph g(1);
boost::graph_traits<graph>::vertex_iterator vb, ve;
boost::tie(vb, ve) = boost::vertices(g);
std::cout << boost::out_degree(*vb, g) << std::endl;
std::cout << boost::in_degree(*vb, g) << std::endl;
}
Prints
0
0