Is there a way to check if a vertex in a graph created using Boost already exists rather than looping through the vertices?
And if it already exists, how can I add a new edge using its vertex descriptor?
Example:
Graph g;
vertex v;
v = add_vertex(1, g);
vertex_name[v] = "root";
v = add_vertex(2, g);
vertex_name[v] = "vert_2";
v = add_vertex(3, g);
vertex_name[v] = "vert_3";
// This is not possible
edge e1;
if (vertex.find("root") == vertex.end()) {
(boost::add_edge("root", "vert_2", g)).first
}
I think you may like the labeled_graph adaptor:
Live On Coliru
Prints: