|
Boost Users : |
From: Stephen Torri (storri_at_[hidden])
Date: 2007-08-28 17:42:45
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<boost::vecS, // OutEdgeList
boost::vecS, // VertexList
boost::directedS, // Directed
VertexProperty_t> //
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<edge_descriptor, bool> 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<Graph_t>::vertex_property_type vertex_propert_obj = Component::ptr ( new Component() );
boost::graph_traits<Graph_t>::vertex_descriptor new_vertex = add_vertex ( vertex_property_obj, m_graph );
Stephen
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net