|
Boost Users : |
Subject: Re: [Boost-users] (no subject)
From: Gabriel Marchand (gabriel.marchand_at_[hidden])
Date: 2011-04-06 13:43:55
I forgot to attach the code in the previous mail! Here it is.
Hi Cedric and thank you for your reply.
Actually I need the
mutable graph type (using listS as vertex container) because I'll need
to use the functions clear_vertex() and remove_vertex(). And I am facing
the problem to create this index map property to the vertices to use
the function
connected_components().
I wrote a more consistent version of the
code (test.cpp attached), following the instructions in a previous post
by Aaron Windsor:
http://boost.2283326.n4.nabble.com/connected-components-td2576097.html
It compiles until I added the last line:
"int num_clusters = connected_components(G, &component[0], vertex_index_map(index));"
The compiler tells:
gmarchand_at_bohr:~/TMP$ g++ test.cpp
In file included from
/usr/include/c++/4.4/backward/hash_set:60,
                from /usr/include/boost/graph/adjacency_list.hpp:25,
                from test.cpp:3:
/usr/include/c++/4.4/backward/backward_warning.h:28:2:
warning: #warning This file includes at least one deprecated or
antiquated header which may be removed without further notice at a
future date. Please use a non-deprecated interface with equivalent
functionality instead. For a listing of replacement headers and
interfaces, consult the file backward_warning.h. To disable this warning
use -Wno-deprecated.
In file included from /usr/include/boost/graph/adjacency_list.hpp:42,
                from
test.cpp:3:
/usr/include/boost/property_map/property_map.hpp: In
member function âvoid boost::WritablePropertyMapConcept<PMap,
Key>::constraints() [with PMap = int*, Key = void*]â:
/usr/include/boost/concept/detail/has_constraints.hpp:40:Â Â
instantiated from âconst bool
boost::concept::not_satisfied<boost::WritablePropertyMapConcept<int*,
void*> >::valueâ
/usr/include/boost/concept/detail/has_constraints.hpp:43:Â Â
instantiated from
âboost::concept::not_satisfied<boost::WritablePropertyMapConcept<int*,
void*> >â
/usr/include/boost/mpl/if.hpp:67:Â Â instantiated
from
âboost::mpl::if_<boost::concept::not_satisfied<boost::WritablePropertyMapConcept<int*,
void*> >,
boost::concept::constraint<boost::WritablePropertyMapConcept<int*,
void*> >,
boost::concept::requirement<boost::WritablePropertyMapConcept<int*,
void*> >
>â
/usr/include/boost/concept/detail/general.hpp:19:Â Â
instantiated from âboost::concept::requirement_<void
(*)(boost::WritablePropertyMapConcept<int*, void*>)>â
/usr/include/boost/concept_check.hpp:43:Â Â
instantiated from âvoid boost::function_requires(Model*) [with Model =
boost::WritablePropertyMapConcept<int*, void*>]â
/usr/include/boost/graph/connected_components.hpp:67:Â Â
instantiated from âtypename
boost::property_traits<IndexMap>::value_type
boost::connected_components(const Graph&, ComponentMap, const
boost::bgl_named_params<P, T, R>&, typename
boost::enable_if_c<boost::is_base_and_derived::value,
boost::graph::detail::no_parameter>::type) [with Graph =
main()::graph_t, ComponentMap = int*, P =
boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS,
boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t,
long unsigned int, boost::no_property>, boost::no_property,
boost::no_property, boost::listS>, long unsigned int, long unsigned
int&, boost::vertex_index_t>, T = boost::vertex_index_t, R =
boost::no_property]â
test.cpp:54:Â Â instantiated from here
/usr/include/boost/property_map/property_map.hpp:195:
error: no matching function for call to âput(int*&, void*&,
int&)â
In file included from test.cpp:4:
/usr/include/boost/graph/connected_components.hpp:
In member function âvoid
boost::detail::components_recorder<ComponentsMap>::discover_vertex(Vertex,
Graph&) [with Vertex = void*, Graph = const
boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t, long unsigned int,
boost::no_property>, boost::no_property, boost::no_property,
boost::listS>, ComponentsMap =
int*]â:
/usr/include/boost/graph/depth_first_search.hpp:103:Â Â
instantiated from âvoid boost::detail::depth_first_visit_impl(const
IncidenceGraph&, typename
boost::graph_traits<Graph>::vertex_descriptor, DFSVisitor&,
ColorMap, TerminatorFunc) [with IncidenceGraph =
boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t, long unsigned int,
boost::no_property>, boost::no_property, boost::no_property,
boost::listS>, DFSVisitor =
boost::detail::components_recorder<int*>, ColorMap =
boost::shared_array_property_map<boost::default_color_type,
boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS,
boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t, long unsigned int,
boost::no_property>, boost::no_property, boost::no_property,
boost::listS>, long unsigned int, long unsigned int&,
boost::vertex_index_t> >, TerminatorFunc =
boost::detail::nontruth2]â
/usr/include/boost/graph/depth_first_search.hpp:201:Â Â
instantiated from âvoid boost::depth_first_search(const
VertexListGraph&, DFSVisitor, ColorMap, typename
boost::graph_traits<Graph>::vertex_descriptor) [with
VertexListGraph = boost::adjacency_list<boost::listS, boost::listS,
boost::undirectedS, boost::property<boost::vertex_index_t, long
unsigned int, boost::no_property>, boost::no_property,
boost::no_property, boost::listS>, DFSVisitor =
boost::detail::components_recorder<int*>, ColorMap =
boost::shared_array_property_map<boost::default_color_type,
boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS,
boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t, long unsigned int,
boost::no_property>, boost::no_property, boost::no_property,
boost::listS>, long unsigned int, long
unsigned int&, boost::vertex_index_t> >]â
/usr/include/boost/graph/depth_first_search.hpp:296:Â Â
instantiated from âvoid boost::depth_first_search(const
VertexListGraph&, const boost::bgl_named_params<P, T, R>&)
[with VertexListGraph = boost::adjacency_list<boost::listS,
boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t, long unsigned int,
boost::no_property>, boost::no_property, boost::no_property,
boost::listS>, P = boost::detail::components_recorder<int*>, T =
boost::graph_visitor_t, R =
boost::bgl_named_params<boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS,
boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t, long unsigned int,
boost::no_property>, boost::no_property, boost::no_property,
boost::listS>, long unsigned int, long unsigned int&,
boost::vertex_index_t>, boost::vertex_index_t,
boost::no_property>]â
/usr/include/boost/graph/connected_components.hpp:75:Â Â
instantiated from âtypename
boost::property_traits<IndexMap>::value_type
boost::connected_components(const Graph&, ComponentMap, const
boost::bgl_named_params<P, T, R>&, typename
boost::enable_if_c<boost::is_base_and_derived::value,
boost::graph::detail::no_parameter>::type) [with Graph =
main()::graph_t, ComponentMap = int*, P =
boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS,
boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t, long unsigned int,
boost::no_property>, boost::no_property, boost::no_property,
boost::listS>, long unsigned int, long unsigned int&,
boost::vertex_index_t>, T = boost::vertex_index_t, R =
boost::no_property]â
test.cpp:54:Â Â instantiated from here
/usr/include/boost/graph/connected_components.hpp:46: error: no matching
function for call to âput(int*&, void*&, int&)â
/usr/include/boost/graph/connected_components.hpp:
In member function âvoid
boost::detail::components_recorder<ComponentsMap>::discover_vertex(Vertex,
Graph&) [with Vertex = void*, Graph =
boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t, long unsigned int,
boost::no_property>, boost::no_property, boost::no_property,
boost::listS>, ComponentsMap = int*]â:
/usr/include/boost/graph/depth_first_search.hpp:38:Â Â
instantiated from âvoid boost::DFSVisitorConcept<Visitor,
Graph>::constraints() [with Visitor =
boost::detail::components_recorder<int*>, Graph =
boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t, long unsigned int,
boost::no_property>, boost::no_property, boost::no_property,
boost::listS>]â
/usr/include/boost/concept/detail/has_constraints.hpp:40:Â Â
instantiated from âconst bool
boost::concept::not_satisfied<boost::DFSVisitorConcept<boost::detail::components_recorder<int*>,
boost::adjacency_list<boost::listS, boost::listS,
boost::undirectedS, boost::property<boost::vertex_index_t, long
unsigned int, boost::no_property>, boost::no_property,
boost::no_property, boost::listS> > >::valueâ
/usr/include/boost/concept/detail/has_constraints.hpp:43:Â Â
instantiated from
âboost::concept::not_satisfied<boost::DFSVisitorConcept<boost::detail::components_recorder<int*>,
boost::adjacency_list<boost::listS, boost::listS,
boost::undirectedS, boost::property<boost::vertex_index_t, long
unsigned int, boost::no_property>, boost::no_property,
boost::no_property, boost::listS> > >â
/usr/include/boost/mpl/if.hpp:67:Â Â
instantiated from
âboost::mpl::if_<boost::concept::not_satisfied<boost::DFSVisitorConcept<boost::detail::components_recorder<int*>,
boost::adjacency_list<boost::listS, boost::listS,
boost::undirectedS, boost::property<boost::vertex_index_t, long
unsigned int, boost::no_property>, boost::no_property,
boost::no_property, boost::listS> > >,
boost::concept::constraint<boost::DFSVisitorConcept<boost::detail::components_recorder<int*>,
boost::adjacency_list<boost::listS, boost::listS,
boost::undirectedS, boost::property<boost::vertex_index_t, long
unsigned int, boost::no_property>, boost::no_property,
boost::no_property, boost::listS> > >,
boost::concept::requirement<boost::DFSVisitorConcept<boost::detail::components_recorder<int*>,
boost::adjacency_list<boost::listS, boost::listS,
boost::undirectedS, boost::property<boost::vertex_index_t, long
unsigned int, boost::no_property>,
boost::no_property, boost::no_property, boost::listS> > >
>â
/usr/include/boost/concept/detail/general.hpp:19:Â Â
instantiated from âboost::concept::requirement_<void
(*)(boost::DFSVisitorConcept<boost::detail::components_recorder<int*>,
boost::adjacency_list<boost::listS, boost::listS,
boost::undirectedS, boost::property<boost::vertex_index_t, long
unsigned int, boost::no_property>, boost::no_property,
boost::no_property, boost::listS> >)>â
/usr/include/boost/concept_check.hpp:43:Â Â
instantiated from âvoid boost::function_requires(Model*) [with Model =
boost::DFSVisitorConcept<boost::detail::components_recorder<int*>,
boost::adjacency_list<boost::listS, boost::listS,
boost::undirectedS, boost::property<boost::vertex_index_t, long
unsigned int, boost::no_property>, boost::no_property,
boost::no_property, boost::listS>
>]â
/usr/include/boost/graph/depth_first_search.hpp:191:Â Â
instantiated from âvoid boost::depth_first_search(const
VertexListGraph&, DFSVisitor, ColorMap, typename
boost::graph_traits<Graph>::vertex_descriptor) [with
VertexListGraph = boost::adjacency_list<boost::listS, boost::listS,
boost::undirectedS, boost::property<boost::vertex_index_t, long
unsigned int, boost::no_property>, boost::no_property,
boost::no_property, boost::listS>, DFSVisitor =
boost::detail::components_recorder<int*>, ColorMap =
boost::shared_array_property_map<boost::default_color_type,
boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS,
boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t, long unsigned int,
boost::no_property>, boost::no_property, boost::no_property,
boost::listS>, long unsigned int, long unsigned int&,
boost::vertex_index_t>
>]â
/usr/include/boost/graph/depth_first_search.hpp:296:Â Â
instantiated from âvoid boost::depth_first_search(const
VertexListGraph&, const boost::bgl_named_params<P, T, R>&)
[with VertexListGraph = boost::adjacency_list<boost::listS,
boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t, long unsigned int,
boost::no_property>, boost::no_property, boost::no_property,
boost::listS>, P = boost::detail::components_recorder<int*>, T =
boost::graph_visitor_t, R =
boost::bgl_named_params<boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS,
boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t, long unsigned int,
boost::no_property>, boost::no_property, boost::no_property,
boost::listS>, long unsigned int, long unsigned int&,
boost::vertex_index_t>, boost::vertex_index_t,
boost::no_property>]â
/usr/include/boost/graph/connected_components.hpp:75:Â Â
instantiated from âtypename
boost::property_traits<IndexMap>::value_type
boost::connected_components(const Graph&, ComponentMap, const
boost::bgl_named_params<P, T, R>&, typename
boost::enable_if_c<boost::is_base_and_derived::value,
boost::graph::detail::no_parameter>::type) [with Graph =
main()::graph_t, ComponentMap = int*, P =
boost::adj_list_vertex_property_map<boost::adjacency_list<boost::listS,
boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t, long unsigned int,
boost::no_property>, boost::no_property, boost::no_property,
boost::listS>, long unsigned int, long unsigned int&,
boost::vertex_index_t>, T = boost::vertex_index_t, R =
boost::no_property]â
test.cpp:54:Â Â instantiated from here
/usr/include/boost/graph/connected_components.hpp:46: error: no matching
function for call to âput(int*&, void*&, int&)â
gmarchand_at_bohr:~/TMP$
I hope it is more clear now,
Gabriel
--- En date de : Mer 6.4.11, Cedric Laczny <cedric.laczny_at_[hidden]> a écrit :
De: Cedric Laczny <cedric.laczny_at_[hidden]>
Objet: Re: [Boost-users] (no subject)
Ã: boost-users_at_[hidden]
Date: Mercredi 6 avril 2011, 16h15
Hi,
On Wednesday, 6. April 2011 12:55:52 Gabriel Marchand wrote:
> Hi, I am new to boost and I face the same problem mentioned here with
> "connected_components()" using a mutable graph (hence using a list for the
> vertex container). I try the detailed solution of Aaron Windsor in the
> previous post but I still get some errors at compilation. Here is my
> little code:
>
>
>
>Â Â Â Â #include <boost/graph/adjacency_list.hpp>
>Â Â Â Â #include <boost/graph/connected_components.hpp>
>
>Â Â Â Â using namespace std;
>Â Â Â Â using namespace boost;
>
>Â Â Â Â Box& b = conf.GetBox();
>
You seem to use your own classes and you do not provide the definition. Thus
this is unfortunately not a minimal example. So in the future, it might
facilitate help from others to you, with this in the back of your head.
>
>Â Â Â Â if (!ai) {
>Â Â Â Â Â Â ai = new AtomList();
>Â Â Â Â Â Â *ai = conf.GetAtoms().AtomSelector(selecti, b);
>Â Â Â Â }
>
>Â Â Â Â typedef boost::adjacency_list<
>Â Â Â Â Â Â Â Â listS,
>Â Â Â Â Â Â Â Â listS,
>Â Â Â Â Â Â Â Â undirectedS,
>Â Â Â Â Â Â Â Â Â property<vertex_index_t, size_t>,
>Â Â Â Â Â Â Â Â Â no_property>
>
>Â Â Â Â > graph_t;
>
>Â Â Â Â graph_t g(ai->size());
>Â Â Â Â property_map<graph_t, vertex_index_t>::type index = get(vertex_index,
> g);
With listS as the vertex container, I would expect it to fail here. An
adjacency_list with listS does not automatically create a vertex_index
property. So you might give vecS a try. Especially, if you insert most of the
vertices (if not all) at one specific moment and you are not constantly
changing the number of vertices in the graph, I think it will make no big
difference in performance whether you use vecS or listS. But you have the
benefit of automatic vertex_index property-creation.
I can however not compile your example (s. above) nor did you provide the
error message you get, so I can't tell you for sure if this is the source of
error.
> graph_traits<graph_t>::vertex_iterator vi, vi_end;
>Â Â Â Â graph_traits<graph_t>::vertices_size_type cnt = 0;
>Â Â Â Â for(tie(vi,vi_end) = vertices(g); vi != vi_end; ++vi)
>Â Â Â Â Â Â put(index, *vi, cnt++);
>
>Â Â Â Â for (unsigned int i = 0; i < ai->size(); ++i) {
>Â Â Â Â Â Â Cartesian& crdi = ai->GetElement(i)->pos;
>Â Â Â Â Â Â for (unsigned int j = i + 1; j < ai->size(); ++j) {
>Â Â Â Â Â Â Â Â Cartesian& crdj = ai->GetElement(j)->pos;
>Â Â Â Â Â Â Â Â double r = conf.GetBox().CartesianDistance(crdi, crdj);
>Â Â Â Â Â Â Â Â if (r < rcut) {
>Â Â Â Â Â Â Â Â Â Â add_edge(vertex(i,g), vertex(j,g), g); // Add edge to Map
> if distance criteria is satisfied
>
>Â Â Â Â Â Â Â Â }
>Â Â Â Â Â Â }
>Â Â Â Â }
>
>Â Â Â Â vector<int> component(num_vertices(g));
>Â Â Â Â int num_clusters = connected_components(g, &component[0],
> vertex_index_map(index));
>
>
>
>
> The compilation is successfull until I add the last line:
>Â int num_clusters = connected_components(g, &component[0],
> vertex_index_map(index));
This confuses me a bit, as I would expect the error in an earlier line.
So you might look forward to provide your error message or a really working,
minimal example.
>
>
> Hope somebody can give a hint
Hope this helps.
> gabriel
Best,
Cedric
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
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