Boost logo

Boost :

From: Doug Gregor (dgregor_at_[hidden])
Date: 2006-07-14 11:26:30


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


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