Boost logo

Boost Users :

From: Emmanuel Viaud (emmanuel.viaud_at_[hidden])
Date: 2007-08-01 10:01:08


Hello.

Using Boost 1.34.1 (with g++-3.4.2) and more specifically the Boost
Graph library, I stumbled on a small problem with the
transitive_closure algorithm.

I saw in the documentation that I can get a map containing the mapping
between the vertices of the original graph and the ones in the
transitive closure graph (the orig_to_copy parameter). But every time
I call the method, I get an empty map as a result.

To sum up my code, I use the following data structures for the graph:

typedef boost::adjacency_list < boost::vecS, boost::vecS,
boost::directedS > graph_t;
typedef boost::graph_traits < graph_t >::vertex_descriptor vertex_t;

and the following one for the expected map:

typedef std::map < vertex_t, vertex_t > ioMap_t;

The graphs and map are declared the following way:

graph_t myGraph;
graph_t myTCGraph;

ioMap_t ioMap;

I used both versions of the algorithm:
 1) using named parameters, I call:
    transitive_closure(myGraph, myTCGraph, orig_to_copy(ioMap));

 2) using "standard" parameters, I call:
    transitive_closure(myGraph, myTCGraph, ioMap, get(vertex_index, myGraph));

So, the main question is easy: Where did I write something wrong ? :-)

A remark though. I see that the declaration in the case of "standard"
parameters is the following :

template <typename Graph, typename GraphTC,
  typename G_to_TC_VertexMap, typename VertexIndexMap>
void transitive_closure(const Graph& g, GraphTC& tc,
                                G_to_TC_VertexMap g_to_tc_map,
VertexIndexMap index_map);

So, if I understand everything (I'm far from speaking C++ fluently),
this means that the g_to_tc_map parameter is passed by value.
Shouldn't it be rather passed by reference (this would explain my
problem as, when debugging my code, I saw that the map is correctly
filled in the transitive_closure method but the caller gets back
nothing at all) ?

Hope I managed to be clear and thanks for your help.

Best regards,
Emmanuel


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