Boost logo

Boost Users :

From: Dmitry (dmitry_at_[hidden])
Date: 2008-06-22 17:25:49


Andrew Schweitzer escribió:
> This is probably in the Graph doc / book somewhere, but after a few
> hours poking around didn't find it...
>
> I added a bunch of vertices, each with a "unique id" property that comes
> from our system.
>
> Then I want to add the edges. Given the "unique id" from our system for
> the From and To vertices of the edge, how do I convert those "unique
> ids" into vertex_descriptors that can be passed to add_edge?
>
> tx
>
> Andy

A simple solution that instantly comes to my mind
is to create a map e.g. std::map<"unique id", Vertex, Comp<"unique id">
> id2v
and use it to convert vertex id to vertex descriptor.

If you use adjacency_list<> with vecS selector for vettices list
and "unique id" is an integer number within the interval
[0, num_vertices ) you may directly write boost::add_edge(id(v1), id(v2))

Hope this will help,

Dmiry


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