I am trying to figure out how to use boost::graph to store some information. However, there is information I want tied to each vertex. Staring at the documentation for the l
Below is code I used to attach some properties to vertices, edges, and graphs. Note that vertex name and graph name are predefined properties (see boost/properties.hpp for a complete list) so that vertex_name_t and graph_name_t are already defined. However, vertex_location_t, edge_length_t, and graph_notes_t are my own properties and hence need definition. I cobbled together this code from various examples and documentation, and I'm not sure exactly what BOOST_INSTALL_PROPERTY does, but the code seems to work fine.
// Define custom properties
enum vertex_location_t { vertex_location };
enum edge_length_t { edge_length };
enum graph_notes_t { graph_notes };
namespace boost
{
BOOST_INSTALL_PROPERTY(vertex, location);
BOOST_INSTALL_PROPERTY(edge, length );
BOOST_INSTALL_PROPERTY(graph, notes );
}
// Define vertex properties: vertex name and location
typedef property >
VertexProperties;
// Define edge properties: length
typedef property EdgeProperties;
// Define graph properties: graph name and notes
typedef property >
GraphProperties;
// Define a graph type
typedef adjacency_list
<
vecS, // edge container type
vecS, // vertex container type
undirectedS,
VertexProperties,
EdgeProperties,
GraphProperties
> Graph;