[BGL] johnson_all_pairs_shortest problem compiling

Hi, Why doesn't the following code compile (VC++ 7.1, g++ 3.3.3, boost 1.31.0) ? ======================================================================== #include <boost/graph/adjacency_list.hpp> #include <boost/graph/johnson_all_pairs_shortest.hpp> int main() { using namespace boost; typedef adjacency_list<vecS, vecS, bidirectionalS, boost::property<boost::vertex_index_t, int, boost::property<boost::edge_weight_t, int> > > Graph; Graph g; int distance_matrix[100][100]; johnson_all_pairs_shortest_paths(g, distance_matrix); } ======================================================================== but it compiles, if we pass the edge weight map (composed from std::map<edge_descriptor, int>) as a named parameter to johnson_all_pairs_shortest_paths ? Also, why do johnson_all_pairs_shortest_paths(g, distance_matrix); and johnson_all_pairs_shortest_paths(g, distance_matrix, weight_map(get(vertex_index, g))); produce completely different compile time errors? Finally, is it possible to use johnson_all_pairs_shortest_paths with adjacency_list<mapS, mapS, ...> ? According to the documentation, this should be possible, but this just does not compile. -- Val Samko http://val.digiways.com/

Hi Val, Thanks for your email! On Apr 4, 2004, at 10:39 AM, Val Samko wrote:
Hi,
Why doesn't the following code compile (VC++ 7.1, g++ 3.3.3, boost 1.31.0) ? ====================================================================== #include <boost/graph/adjacency_list.hpp> #include <boost/graph/johnson_all_pairs_shortest.hpp> int main() { using namespace boost; typedef adjacency_list<vecS, vecS, bidirectionalS,
boost::property<boost::vertex_index_t, int,
boost::property<boost::edge_weight_t, int> >
Graph; Graph g; int distance_matrix[100][100]; johnson_all_pairs_shortest_paths(g, distance_matrix); } ======================================================================
You've specified edge_weight_t as a vertex property. Instead you should have adjacency_list<vecS, vecS, bidirectionalS, property<vertex_index_t, int>, property<edge_weight_t, int> > also, note that since you've got VertexList=vecS, there is a built-in vertex index, so you should instead just have adjacency_list<vecS, vecS, bidirectionalS, no_property, property<edge_weight_t, int> >
but it compiles, if we pass the edge weight map (composed from std::map<edge_descriptor, int>) as a named parameter to johnson_all_pairs_shortest_paths ?
Also, why do johnson_all_pairs_shortest_paths(g, distance_matrix); and johnson_all_pairs_shortest_paths(g, distance_matrix, weight_map(get(vertex_index, g))); produce completely different compile time errors?
Because they are different errors. The second error is that get(vertex_index, g) does not return an edge weight map, which is what weight_map() is expecting.
Finally, is it possible to use johnson_all_pairs_shortest_paths with adjacency_list<mapS, mapS, ...> ? According to the documentation, this should be possible, but this just does not compile.
It is suppose to work... There were some bugs in johnson's with respect to this. I've checked in fixes. Also, with mapS you will need to specify vertex_index_t as an internal vertex property map of the adjacency_list. Cheers, Jeremy _______________________________________________ Jeremy Siek <jsiek@osl.iu.edu> http://www.osl.iu.edu/~jsiek Ph.D. Student, Indiana University Bloomington Graduating in August 2004 and looking for work C++ Booster (http://www.boost.org) _______________________________________________

Hi Jeremy, Thanks for your help. JS> You've specified edge_weight_t as a vertex property. Instead you should JS> have silly me ... this was the source of my problem.
Finally, is it possible to use johnson_all_pairs_shortest_paths with adjacency_list<mapS, mapS, ...> ? According to the documentation, this should be possible, but this just does not compile.
JS> It is suppose to work... JS> There were some bugs in johnson's with respect to this. I've checked in JS> fixes. JS> Also, with mapS you will need to specify vertex_index_t as an internal JS> vertex property map of the adjacency_list. I tried that, it didn't help, I hope your fixes fix this. -- Val Samko http://val.digiways.com/
participants (2)
-
Jeremy Siek
-
Val Samko