|
Boost Users : |
From: Aaron Windsor (aaron.windsor_at_[hidden])
Date: 2007-10-08 07:46:38
On 10/7/07, Ning Ruan <nruan_at_[hidden]> wrote:
> my code to use transitive_closure():
> Graph tc;
> VertexIndexMap index_map = get(&VertexProp::id, g);
> vector<Vertex> to_tc_vec(num_vertices(g));
> iterator_property_map<Vertex*, VertexIndexMap, Vertex, Vertex&>
> g_to_tc_map(&to_tc_vec[0], index_map);
> transitive_closure(graph, tc, g_to_tc_map, (index_map));
>
> I use print_graph(tc, get(&VertexProp::id, tc) to print the transitive
> graph, then it shows:
> 0 --> 0 0 0 0 0 0 0 0
> 0 --> 0 0
> 0 -->
> 0 --> 0 0 0 0 0 0 0 0
> 0 -->
> 0 -->
> 0 --> 0 0 0
> 0 --> 0 0 0 0 0 0 0 0
>
> the result miss the id of vertex, what 's the problem. my original graph
> g is correcet:
>
> 0 --> 1 2 3
> 1 --> 4 5
> 2 -->
> 3 --> 6 7
> 4 -->
> 5 -->
> 6 --> 1
> 7 --> 0
Hi Ning,
Do you ever initialize the VertexProp::id property? For example:
VertexIndexMap index_map = get(&VertexProp::id, g);
graph_traits<Graph>::vertices_size_type count = 0;
graph_traits<Graph>::vertex_iterator vi, vi_end;
for(tie(vi, vi_end) = vertices(tc); vi != vi_end; ++vi)
index_map[*vi] = count++;
If you aren't initializing it, that's the problem. If you are
initializing it, please show a little more of your code - in
particular the typedef you're using for Graph.
Regards,
Aaron
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