|
Boost Users : |
Subject: [Boost-users] [Graph] How to get the key given a value in property_map
From: Phani Deepak Parasuramuni (phanidee_at_[hidden])
Date: 2009-04-21 15:36:57
hi,
i want to name the vertices and add the edges between vertices by
referring to their names dynamicaly.
i 'll have something like this.
typedef boost::property<boost::vertex_name_t, string> VName;
typedef boost::adjacency_list<boost::vecS, boost::vecS,
boost::directedS, VName > Graph;
typedef boost::property_map<Graph, boost::vertex_name_t>::type
VertexNames;
Graph g;
VertexNames names = get(vertex_name, g);
boost::add_vertex(VName("me") , g);
boost::add_vertex(VName("myNeighbour") , g);
i want to be able to do something like this.
boost::add_edge( names.getKey("me"), names.getKey("myNeighbour") ,g);
// but there is no any such kind of property_map
i looked around and found that there are ways to get the name of vertex if i
have a vertex_descriptor
but how can i get a vertex_descriptor given the vertex_name
there are only three ops defined on property_map :- get,put,iterator;
is there any other way to get the key from value other than iterating
through all the pairs
in property_map & matching each pair.second with vertex_name?
pardon me if it is a basic thing, i just cant able to get at it.
Any help would be greatly appreciated.
Thanks,
Phani.
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