
Boost Users : 
From: Jeremy Siek (jsiek_at_[hidden])
Date: 20040404 13:17:36
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 builtin
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_at_[hidden]>
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)
_______________________________________________
Boostusers 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