Boost logo

Boost :

From: Wang Weiwei (wwwang_at_[hidden])
Date: 2006-07-15 03:07:27


>
>On Jul 14, 2006, at 10:54 AM, Wang Weiwei wrote:
>
>> Hello,
>>
>> I have a graph type as follows:
>>
>> namespace boost
>> {
>> enum vertex_flag_t { vertex_flag = 111 };
>> BOOST_INSTALL_PROPERTY(vertex, flag);
>> }
>>
>> typedef boost::adjacency_list<boost::vecS, boost::vecS,
>> boost::undirectedS,
>> property<vertex_name_t, std::string,
>> property<vertex_flag_t, bool,
>> property<vertex_color_t, default_color_type> > >,
>> no_property> graph_t;
>>
>> graph_t g;
>>
>> That means I want to associate a string as name, a flag, and a
>> default color to each vertex of my graph,
>> now I want to add edges to my graph directly using the vertex'
>> properties instead of their descriptors,
>> e.g.
>>
>> boost::add_edge("vertex1", "vertex2", g);
>>
>> How can I accomplish this?
>
>You'll need to create a separate mapping from vertex names to vertex
>descriptors:
>
> std::map<std::string, graph_t::vertex_descriptor> name_to_vertex;
>
> Doug

Hello, Doug,

Yes, I also got the right way from the BGL book.

The main reason I ask this question here is that I hope/guess there may be a more
BGL-native way to do this, with it in mind that I'm not very familiar with the
whole library.

Thank you very much.

Max


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk