
On Wed, 1 Sep 2010, Bruno Barberi Gnecco wrote:
Hi,
I want to store pointers in a graph. Can I somehow use their pointers as indexes?
Here's the code I'm trying to execute. It does not work correctly, however; apparently graph add other nodes in the vector storage (to fill the holes?). I suppose I could use listS instead of vecS, but then I can't get the topological_sort code to work (I know I have to provide some form of indices, but I don't understand how to do that). Any suggestions to solve this?
Would you rather have your pointers as indices or use listS? If you use listS, you get stable pointers as descriptors, but you can't choose the pointer; it is allocated by BGL. If you want to use your pointers, you will need to either create your own graph type or (more likely) have a separate map or unordered_map from your pointers to graph vertices and then have the pointer also be a vertex property (for two-way linkage). If you can modify the definition of Plugin, you can add a vertex descriptor there. Note that you need listS or similar to get stable descriptors. As to the topological_sort issue, you have two main options: create your own color map, or create a vertex index map. Since you are setting up your own properties anyway, you might want to have vertex_color as a vertex property and have another property for the Plugin* (using either old-style or bundled properties). You can also use associative_property_map (at some loss in performance) as the color map; that is the easy option. I do not see an obvious example of that around, but URL:http://www.boost.org/doc/libs/1_44_0/libs/property_map/doc/associative_p... will give you a start. -- Jeremiah Willcock