Usage of Transitive_closure().
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
On 10/7/07, Ning Ruan <nruan@cs.kent.edu> 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
Thank you very much. I forget to initialize the indexmap, it works now. Ning Aaron Windsor wrote:
On 10/7/07, Ning Ruan <nruan@cs.kent.edu> 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 mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi, Aaron, I am sorry it just work one time and doesn't work again I have initialized the indexMap, the result show that 528 --> 0 0 0 0 0 528 0 0 0 --> 0 0 0 --> 0 --> 0 0 0 0 0 528 0 0 0 --> 0 --> 0 --> 0 0 0 0 --> 0 0 0 0 0 528 0 0 my graph sturcture: // vertex property struct VertexProp { size_t id; int level; //for tree instance int pre_order; int post_order; }; // edge property struct EdgeProp { int id; // for tree or non-tree bool tree; // 1: tree; 0: non-tree bool mark; // 1: processed; 0: not yet }; // graph typedef adjacency_list<listS, listS, bidirectionalS, VertexProp, EdgeProp> Graph; typedef graph_traits<Graph>::vertex_descriptor Vertex; typedef graph_traits<Graph>::edge_descriptor Edge; my operation code: VertexIndexMap index_map = get(&VertexProp::id, g); graph_traits<Graph>::vertices_size_type count = 0; graph_traits<Graph>::vertex_iterator vi1, vi_end1; for (tie(vi1, vi_end1) = vertices(tc); vi1 != vi_end1; vi1++) index_map[*vi1] = count++; 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(g, tc, g_to_tc_map, (index_map)); Aaron Windsor wrote:
On 10/7/07, Ning Ruan <nruan@cs.kent.edu> 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 mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On 10/8/07, nruan <nruan@cs.kent.edu> wrote:
Hi, Aaron, I am sorry it just work one time and doesn't work again I have initialized the indexMap, the result show that 528 --> 0 0 0 0 0 528 0 0 0 --> 0 0 0 --> 0 --> 0 0 0 0 0 528 0 0 0 --> 0 --> 0 --> 0 0 0 0 --> 0 0 0 0 0 528 0 0
my graph sturcture:
// vertex property struct VertexProp { size_t id; int level; //for tree instance int pre_order; int post_order; };
// edge property struct EdgeProp { int id; // for tree or non-tree bool tree; // 1: tree; 0: non-tree bool mark; // 1: processed; 0: not yet };
// graph typedef adjacency_list<listS, listS, bidirectionalS, VertexProp, EdgeProp> Graph;
typedef graph_traits<Graph>::vertex_descriptor Vertex; typedef graph_traits<Graph>::edge_descriptor Edge;
my operation code: VertexIndexMap index_map = get(&VertexProp::id, g); graph_traits<Graph>::vertices_size_type count = 0; graph_traits<Graph>::vertex_iterator vi1, vi_end1; for (tie(vi1, vi_end1) = vertices(tc); vi1 != vi_end1; vi1++) index_map[*vi1] = count++; 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(g, tc, g_to_tc_map, (index_map));
Aaron Windsor wrote:
On 10/7/07, Ning Ruan <nruan@cs.kent.edu> 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
Hi Ning, You need to initialize g's vertex index map, not tc's vertex index map, as per the documentation. Sorry if my previous answer was misleading - I had a "tc" where a "g" should have been. Regards, Aaron
participants (3)
-
Aaron Windsor
-
Ning Ruan
-
nruan