BGL: need help with connected_components and boost::setS
Hi all, can anyone help me with the compile error I get when compiling the following code? I'm using the MSVC 7.1 compiler (but it is not an internal compiler error). The error occurs in the last line. Your help is appreciated! With kind regards Maarten #include <boost/graph/graph_traits.hpp> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/connected_components.hpp> // Identifies the "component number" property struct component_t { enum { num = 4564 }; typedef boost::vertex_property_tag kind; }; void Test() { using namespace boost; // The "component number" property is an integer for each vertex typedef boost::property<component_t, int> VertexComponentProperty; // A graph with list storage and the "component number" property. typedef boost::adjacency_list < boost::setS, boost::setS, boost::undirectedS, VertexComponentProperty > Graph; // The property map typedef boost::property_map<Graph, component_t>::type ComponentPropertyMap; Graph g; ComponentPropertyMap vertexToComponent = boost::get(component_t(), g); // THIS LINE DOES NOT COMPILE. No problem if boost::vecS is used instead of boost::setS in the Graph typedef! connected_components(g, vertexToComponent); } __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
On Fri, 2007-04-13 at 04:50 -0700, Maarten Nieber wrote:
Graph g; ComponentPropertyMap vertexToComponent = boost::get(component_t(), g);
// THIS LINE DOES NOT COMPILE. No problem if boost::vecS is used instead of boost::setS in the Graph typedef! connected_components(g, vertexToComponent); }
I believe you do not want the () after the word component_t. In my examples I do not have boost::property_map<Graph_Base::Graph_t, boost::vertex_name_t>::type clist = boost::get(boost::vertex_name, m_graph); I think you want the line to read: Graph g; ComponentPropertyMap vertexToComponent = boost::get(component_t, g); Stephen
Hi Maarten!
can anyone help me with the compile error I get when compiling the following code? [...]
typedef boost::adjacency_list < boost::setS, boost::setS, boost::undirectedS, VertexComponentProperty > Graph;
According to the documentation, the second template argument of adjacency_list (VertexList) should select either a Sequence (e.g., std::list) or RandomAccessContainer (e.g., std::vector). So apparently this argument should not select a set! For the first template argument (OutEdgeList), it's okay to be boost::setS, though. OutEdgeList is allowed to select either a Sequence or an AssociativeContainer. http://www.boost.org/libs/graph/doc/using_adjacency_list.html Does that answer your question? See you tomorrow at LKEB! :-) -- Niels Dekker http://www.xs4all.nl/~nd/dekkerware Scientific programmer at LKEB, Leiden University Medical Center
participants (3)
-
Maarten Nieber
-
Niels Dekker - mail address until 2007-11-30
-
Stephen Torri