I made this property graph according to the documentation:
class Component {
public:
typedef boost::shared_ptr<Component> ptr_t;
};
class My_Graph {
typedef boost::property< boost::vertex_name_t,
Component::ptr_t >
VertexProperty_t;
typedef boost::adjacency_list //
VertexProperties
Graph_t;
Graph_t m_graph;
};
I cannot see from the MutablePropertyGraph page how I am suppose to add
the VertexProperty_t to the vertex when its created. The documentation
for the MutablePropertyGraph shows a use of "add_vertex" giving a
vertex_propety_type with the graph.
template <class G>
struct MutablePropertyGraphConcept
{
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
void constraints() {
function_requires< MutableGraphConcept<G> >();
v = add_vertex(vp, g);
p = add_edge(u, v, ep, g);
}
G g;
std::pair p;
typename boost::graph_traits<G>::vertex_descriptor u, v;
typename boost::graph_traits<G>::vertex_property_type vp;
typename boost::graph_traits<G>::edge_property_type ep;
};
My confusion lies in the fact that the add_vertex function requires a
vertex_property_type the first parameter. So I am unsure how to create a
vertex_property_type from a Component::ptr. Is a vertex_property_type
equivalent to a Component::ptr?
boost::graph_traits::vertex_property_type vertex_propert_obj = Component::ptr ( new Component() );
boost::graph_traits::vertex_descriptor new_vertex = add_vertex ( vertex_property_obj, m_graph );
Stephen