My requirement is to have a graph structure where each vertex is uniquely identified by a boost::uuids::uuid
. All vertices have a color property by which vertic
I remember the library has a labeled_graph
utility that supports this roughly. It has a high convenience factor and I seem to remember it being less interesting in terms of efficiency¹. There should be a sample using it:
Regardless (and referring back to your previous question) you can certainly use an external property map. This has benefits:
you can have the reverse index that you require, see e.g.
Cut set of a graph, Boost Graph Library (where it is used to get reverse-lookup of the colour map).
It also contains an equivalent approach but using Boost Multi-index Containers, which is much more flexible even
find vertex through
boost::vertex_index_t
value
Yes, but if you want to be efficient, indeed you need to either have an external mapping for the reverse lookup OR use your own datastructure and adapt it to model the Graph Concepts you require (much more work, obviously)
iterate through a
boost::property_map
You can. Use boost::get(tag, graph)
to get the property map, iterate across all entities you want to visit and invoke the property map for each property. E.g.
boost::property_map<Graph, boost::vertex_index_t>::type pmap = boost::get(boost::vertex_index, graph);
boost::graph_traits<Graph>::vertex_iterator b, e;
for (boost::tie(b,e) = boost::vertices(graph); b!=e; ++b)
std::cout << "The vertex ID is: " << boost::get(pmap, *b) << "\n";
synchronizing an external
std::map
orbimap
withindex
property
The above links should give you ideas
¹ that would explain I haven't used it myself.