Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use boost::graph algorithms with listS, setS as vertex/edge containers?
    primarykey
    data
    text
    <p>The boost examples for usage of the boost::graph library usually employ a graph like </p> <pre><code>using namespace boost; typedef adjacency_list &lt; vecS, // edge container vecS, // vertex container undirectedS, property&lt;vertex_index_t, int&gt;, property&lt;edge_index_t, int&gt; &gt; graph; </code></pre> <p>and therefore they work very well. But I have a graph with </p> <pre><code>typedef adjacency_list &lt; setS, // edge container listS, // vertex container undirectedS, boost::no_property, // vertex property boost::no_property // edge property &gt; graph; </code></pre> <p>and the algorithms don't work out of the box. In most cases a map for looking up a vertex_descriptor for a particular vertex index (integer value) has to be provided. </p> <p>I want to check whether my graph is planar and compute a planar embedding of it. I provide a vertex index map and it does work in that way for e.g. the connected_components algorithm, but obviously not for the boyer_myrvold_planarity_test:</p> <pre><code>using namespace boost; typedef adjacency_list &lt;boost::setS, boost::listS, undirectedS, boost::no_property, boost::no_property&gt; graph; typedef boost::graph_traits&lt;graph&gt;::edge_descriptor EdgeDesc; typedef boost::graph_traits&lt;graph&gt;::vertex_descriptor VertexDesc; typedef std::map&lt;VertexDesc, size_t&gt; VertexDescMap; typedef std::map&lt;EdgeDesc, size_t&gt; EdgeDescMap; typedef boost::graph_traits&lt;graph&gt;::vertex_iterator VertexIterator; graph K_4; std::vector&lt;VertexDesc&gt; vertex; for(int i=0;i &lt; 4; ++i){ VertexDesc v = boost::add_vertex(K_4); vertex.push_back(v); } add_edge(vertex[0], vertex[1], K_4); add_edge(vertex[0], vertex[2], K_4); add_edge(vertex[0], vertex[3], K_4); add_edge(vertex[1], vertex[2], K_4); add_edge(vertex[1], vertex[3], K_4); add_edge(vertex[2], vertex[3], K_4); VertexDescMap vidxMap; boost::associative_property_map&lt;VertexDescMap&gt; vindexMap(vidxMap); VertexIterator di, dj; boost::tie(di, dj) = boost::vertices(K_4); for(int i = 0; di != dj; ++di,++i){ boost::put(vindexMap, (*di), i); } if (boyer_myrvold_planarity_test( boost::boyer_myrvold_params::graph = K_4, boost::boyer_myrvold_params::vertex_index_map = vindexMap)) std::cout &lt;&lt; "K_4 is planar." &lt;&lt; std::endl; else std::cout &lt;&lt; "ERROR! K_4 should have been recognized as planar!" &lt;&lt; std::endl; </code></pre> <p>It results in various cryptic template errors...</p> <pre><code>&gt; 1&gt;main.cpp &gt; 1&gt;C:\Libraries\PCL-1.5.1\3rdParty\Boost\include\boost/graph/boyer_myrvold_planar_test.hpp(167) &gt; : error C2664: &gt; 'boost::boyer_myrvold_impl&lt;Graph,VertexIndexMap,StoreOldHandlesPolicy,StoreEmbeddingPolicy&gt;::boyer_myrvold_impl(const &gt; Graph &amp;,VertexIndexMap)': Konvertierung des Parameters 2 von 'const &gt; boost::adj_list_vertex_property_map&lt;Graph,ValueType,Reference,Tag&gt;' in &gt; 'vertex_index_map_t' nicht möglich 1&gt; with 1&gt; [ 1&gt; &gt; Graph=graph_t, 1&gt; VertexIndexMap=vertex_index_map_t, 1&gt; &gt; StoreOldHandlesPolicy=boost::graph::detail::no_old_handles, 1&gt; &gt; StoreEmbeddingPolicy=boost::graph::detail::recursive_lazy_list 1&gt; &gt; ] 1&gt; and 1&gt; [ 1&gt; Graph=graph_t, 1&gt; &gt; ValueType=boost::detail::error_property_not_found, 1&gt; &gt; Reference=const boost::detail::error_property_not_found &amp;, 1&gt; &gt; Tag=boost::vertex_index_t 1&gt; ] 1&gt; Kein &gt; benutzerdefinierter Konvertierungsoperator verfügbar, der diese &gt; Konvertierung durchführen kann, oder der Operator kann nicht &gt; aufgerufen werden 1&gt; &gt; C:\Libraries\PCL-1.5.1\3rdParty\Boost\include\boost/graph/boyer_myrvold_planar_test.hpp(259): &gt; Siehe Verweis auf die Instanziierung der gerade kompilierten &gt; Funktions-template "bool &gt; boost::boyer_myrvold_params::core::dispatched_boyer_myrvold&lt;ArgumentPack&gt;(const &gt; ArgumentPack &amp;,boost::mpl::false_,boost::mpl::true_)". 1&gt; with &gt; 1&gt; [ 1&gt; &gt; ArgumentPack=boost::parameter::aux::arg_list&lt;boost::parameter::aux::tagged_argument&lt;boost::boyer_myrvold_params::tag::embedding,const &gt; boost::bgl_named_params&lt;boost::associative_property_map&lt;VertexDescMap&gt;,boost::vertex_index_t,boost::no_property&gt;&gt;,boost::parameter::aux::arg_list&lt;boost::parameter::aux::tagged_argument&lt;boost::boyer_myrvold_params::tag::graph,const &gt; boost::adjacency_list&lt;boost::setS,boost::listS,boost::undirectedS,boost::no_property,boost::no_property&gt;&gt;,boost::parameter::aux::empty_arg_list&gt;&gt; 1&gt; ] 1&gt; &gt; C:\Libraries\PCL-1.5.1\3rdParty\Boost\include\boost/graph/boyer_myrvold_planar_test.hpp(281): &gt; Siehe Verweis auf die Instanziierung der gerade kompilierten &gt; Funktions-template "bool &gt; boost::boyer_myrvold_params::core::boyer_myrvold_planarity_test&lt;boost::parameter::aux::arg_list&lt;TaggedArg,Next&gt;&gt;(const ArgumentPack &amp;)". 1&gt; with 1&gt; [ 1&gt; &gt; TaggedArg=boost::parameter::aux::tagged_argument&lt;boost::boyer_myrvold_params::tag::embedding,const &gt; boost::bgl_named_params&lt;boost::associative_property_map&lt;VertexDescMap&gt;,boost::vertex_index_t,boost::no_property&gt;&gt;, &gt; 1&gt; &gt; Next=boost::parameter::aux::arg_list&lt;boost::parameter::aux::tagged_argument&lt;boost::boyer_myrvold_params::tag::graph,const &gt; boost::adjacency_list&lt;boost::setS,boost::listS,boost::undirectedS,boost::no_property,boost::no_property&gt;&gt;,boost::parameter::aux::empty_arg_list&gt;, 1&gt; &gt; ArgumentPack=boost::parameter::aux::arg_list&lt;boost::parameter::aux::tagged_argument&lt;boost::boyer_myrvold_params::tag::embedding,const &gt; boost::bgl_named_params&lt;boost::associative_property_map&lt;VertexDescMap&gt;,boost::vertex_index_t,boost::no_property&gt;&gt;,boost::parameter::aux::arg_list&lt;boost::parameter::aux::tagged_argument&lt;boost::boyer_myrvold_params::tag::graph,const &gt; boost::adjacency_list&lt;boost::setS,boost::listS,boost::undirectedS,boost::no_property,boost::no_property&gt;&gt;,boost::parameter::aux::empty_arg_list&gt;&gt; 1&gt; ] 1&gt; .\src\main.cpp(135): Siehe Verweis auf die &gt; Instanziierung der gerade kompilierten Funktions-template "bool &gt; boost::boyer_myrvold_planarity_test&lt;graph,boost::bgl_named_params&lt;T,Tag,Base&gt;&gt;(const &gt; A0 &amp;,const A1 &amp;)". 1&gt; with 1&gt; [ 1&gt; &gt; T=boost::associative_property_map&lt;VertexDescMap&gt;, 1&gt; &gt; Tag=boost::vertex_index_t, 1&gt; Base=boost::no_property, 1&gt; &gt; A0=graph, 1&gt; &gt; A1=boost::bgl_named_params&lt;boost::associative_property_map&lt;VertexDescMap&gt;,boost::vertex_index_t,boost::no_property&gt; 1&gt; ] </code></pre> <p>In brief, it complains that it cannot convert/use it as I would like it. </p> <p>How can I make it work? </p> <p>What else do I have to give to the function?</p> <p>Unfortunately, there are hardly boost examples for working with setS or listS as containers. Furthermore, I cannot use the property tags because this is part of a larger implementation and I need to keep the properties external. </p> <p>I would be very happy if somebody has a suggestion. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload