I have to include <boost/graph/adjacency_list.hpp>
to build an adjacency_matrix, or the code will fail to compile.
I don't understand why, those examples I saw do not need it.
#include <boost/graph/adjacency_matrix.hpp>
#include <boost/graph/graph_utility.hpp>
using namespace boost;
typedef boost::adjacency_matrix< directedS > MatrixGraph;
int main(){
const char* name = "ABCD";
MatrixGraph mg(3);
add_edge (0, 1, mg);
add_edge (0, 3, mg);
add_edge (1, 2, mg);
add_edge (2, 3, mg);
boost::print_vertices(mg,name);
}
You forgot to list the error message.
But I think I reproduced it on GCC 4.9 with Boost 1.58;
/home/sehe/custom/boost_1_58_0/boost/graph/detail/edge.hpp|111 col 10| error: ‘hash’ is not a class template
|| struct hash<boost::detail::edge_desc_impl<D, V> >
The fix is
#include <boost/functional/hash.hpp>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.