[Graph] problem with set_property method when using subgraph?

Hi, I wanted to set meaningful names for individual subgraphs but I failed with the following test code.... ---------------------------------------------------------------------------- --------------- typedef adjacency_list<vecS, vecS, directedS,no_property, no_property, property<graph_name_t, string> > mygraph_t; typedef subgraph < graph_t > mysubgraph_t; graph_t g; boost::set_property(g, graph_name, "graph"); // **** this is O.K. mysubgraph G; boost::set_property(G, graph_name, "subgraph"); // **** Error C2784 cout << boost::get_property(G, graph_name) << endl; ---------------------------------------------------------------------------- - I use .NET 2003. The error message says: could not deduce template argument for 'boost::adjacency_list<OutEdgeListS,VertexListS,DirectedS,VertexProperty,Edg eProperty,GraphProperty,EdgeListS> &' from 'mysubraph_t' Any thoughts? Thanks, Daniel

Hi Daniel, There is no set_property function defined in public interface of adjacency_list or subgraph. (there is an undocumented set_property function for adjacency_list. I forget why that function is there.) In any event, the documented get_property function returns a reference, so you can use it to get and set. I know this is confusing... sorry! Here's a working example: #include <string> #include <iostream> #include <boost/cstdlib.hpp> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/subgraph.hpp> int main() { using namespace boost; using std::string; typedef adjacency_list<vecS, vecS, directedS,no_property, property<edge_index_t, int>, property<graph_name_t, string> > graph_t; graph_t g; get_property(g, graph_name) = "graph"; std::cout << "name: " << get_property(g, graph_name) << std::endl; typedef subgraph<graph_t> subgraph_t; subgraph_t sg; get_property(sg, graph_name) = "subgraph"; std::cout << "name: " << get_property(sg, graph_name) << std::endl; return exit_success; } Cheers, Jeremy _______________________________________________ Jeremy Siek <jsiek@osl.iu.edu> http://www.osl.iu.edu/~jsiek Ph.D. Student, Indiana University Bloomington C++ Booster (http://www.boost.org) _______________________________________________
participants (2)
-
Daniel Lou
-
Jeremy Siek