Boost logo

Boost Users :

From: nruan (nruan_at_[hidden])
Date: 2007-10-08 12:03:59


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_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 mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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