
Andrew Sutton pisze:
Does "add_vertex" check the existence of added vertices of given index? No, it doesn't. Or I do something wrong.
For a short answer: never.
Well, it seemed that sometimes yes. I looked at the piece of code of add_vertex in a boost/graph header file: template <class Graph, class Config, class Base> inline typename Config::vertex_descriptor add_vertex(const typename Config::vertex_property_type& p, vec_adj_list_impl<Graph, Config, Base>& g_) { typedef typename Config::vertex_descriptor vertex_descriptor; Graph& g = static_cast<Graph&>(g_); if (optional<vertex_descriptor> v = g.vertex_by_property(get_property_value(p, vertex_bundle))) return *v; typedef typename Config::stored_vertex stored_vertex; g.m_vertices.push_back(stored_vertex(p)); g.added_vertex(g.m_vertices.size() - 1); return g.m_vertices.size() - 1; } So, with property defined as follows property_type: typedef property<vertex_index_t,string> VIndex; Undoubtedly, above add_vertex function searches vertex by properties and should return descriptor of found vertex. Indeed, it doesn't. I'm a little bit confused.
For a longer answer... It looks like vertices are dynamically allocated and the vertex set (listS, setS, etc.) stores pointers to those vertices. In the case of associate containers, the key_type is just the pionter value. In otherwords, add_vertex will never look for a previous instance of the vertex.
Andrew Sutton andrew.n.sutton@gmail.com <mailto:andrew.n.sutton@gmail.com>
Regards liquid