Como usar algoritmos boost :: graph com listS, setS como containers de vértice / borda?

Os exemplos de boost para uso da biblioteca boost :: graph geralmente empregam um grafo como

using namespace boost;
typedef adjacency_list
    < vecS, // edge container 
      vecS, // vertex container
      undirectedS,
      property<vertex_index_t, int>,
      property<edge_index_t, int>
    > graph;

e, portanto, eles funcionam muito bem. Mas eu tenho um gráfico com

typedef adjacency_list
   < setS, // edge container 
     listS, // vertex container
     undirectedS,
     boost::no_property,  // vertex property
     boost::no_property // edge property
   > graph;

e os algoritmos não funcionam fora da caixa. Na maioria dos casos, um mapa para procurar um vertex_descriptor para um determinado índice de vértices (valor inteiro) deve ser fornecido.

Eu quero verificar se o meu gráfico é planar e calcular uma incorporação planar dele. Eu forneço um mapa de índice de vértices e ele funciona dessa forma por ex. o algoritmo connected_components, mas obviamente não para o boyer_myrvold_planarity_test:

using namespace boost;

typedef adjacency_list
<boost::setS, boost::listS, undirectedS,
     boost::no_property, boost::no_property> graph;

typedef  boost::graph_traits<graph>::edge_descriptor    EdgeDesc;
typedef boost::graph_traits<graph>::vertex_descriptor   VertexDesc;

typedef std::map<VertexDesc, size_t> VertexDescMap;
typedef std::map<EdgeDesc, size_t> EdgeDescMap;
typedef boost::graph_traits<graph>::vertex_iterator VertexIterator;


graph K_4;

std::vector<VertexDesc> vertex;
for(int i=0;i < 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<VertexDescMap> 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 << "K_4 is planar." << std::endl;
  else
    std::cout << "ERROR! K_4 should have been recognized as planar!" 
          << std::endl;

Isso resulta em vários erros de gabarito enigmático ...

> 1>main.cpp
> 1>C:\Libraries\PCL-1.5.1\3rdParty\Boost\include\boost/graph/boyer_myrvold_planar_test.hpp(167)
> : error C2664:
> 'boost::boyer_myrvold_impl<Graph,VertexIndexMap,StoreOldHandlesPolicy,StoreEmbeddingPolicy>::boyer_myrvold_impl(const
> Graph &,VertexIndexMap)': Konvertierung des Parameters 2 von 'const
> boost::adj_list_vertex_property_map<Graph,ValueType,Reference,Tag>' in
> 'vertex_index_map_t' nicht möglich 1>        with 1>        [ 1>      
> Graph=graph_t, 1>            VertexIndexMap=vertex_index_map_t, 1>    
> StoreOldHandlesPolicy=boost::graph::detail::no_old_handles, 1>        
> StoreEmbeddingPolicy=boost::graph::detail::recursive_lazy_list 1>     
> ] 1>        and 1>        [ 1>            Graph=graph_t, 1>           
> ValueType=boost::detail::error_property_not_found, 1>           
> Reference=const boost::detail::error_property_not_found &, 1>         
> Tag=boost::vertex_index_t 1>        ] 1>        Kein
> benutzerdefinierter Konvertierungsoperator verfügbar, der diese
> Konvertierung durchführen kann, oder der Operator kann nicht
> aufgerufen werden 1>       
> C:\Libraries\PCL-1.5.1\3rdParty\Boost\include\boost/graph/boyer_myrvold_planar_test.hpp(259):
> Siehe Verweis auf die Instanziierung der gerade kompilierten
> Funktions-template "bool
> boost::boyer_myrvold_params::core::dispatched_boyer_myrvold<ArgumentPack>(const
> ArgumentPack &,boost::mpl::false_,boost::mpl::true_)". 1>        with
> 1>        [ 1>           
> ArgumentPack=boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::boyer_myrvold_params::tag::embedding,const
> boost::bgl_named_params<boost::associative_property_map<VertexDescMap>,boost::vertex_index_t,boost::no_property>>,boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::boyer_myrvold_params::tag::graph,const
> boost::adjacency_list<boost::setS,boost::listS,boost::undirectedS,boost::no_property,boost::no_property>>,boost::parameter::aux::empty_arg_list>> 1>        ] 1>       
> C:\Libraries\PCL-1.5.1\3rdParty\Boost\include\boost/graph/boyer_myrvold_planar_test.hpp(281):
> Siehe Verweis auf die Instanziierung der gerade kompilierten
> Funktions-template "bool
> boost::boyer_myrvold_params::core::boyer_myrvold_planarity_test<boost::parameter::aux::arg_list<TaggedArg,Next>>(const ArgumentPack &)". 1>        with 1>        [ 1>           
> TaggedArg=boost::parameter::aux::tagged_argument<boost::boyer_myrvold_params::tag::embedding,const
> boost::bgl_named_params<boost::associative_property_map<VertexDescMap>,boost::vertex_index_t,boost::no_property>>,
> 1>           
> Next=boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::boyer_myrvold_params::tag::graph,const
> boost::adjacency_list<boost::setS,boost::listS,boost::undirectedS,boost::no_property,boost::no_property>>,boost::parameter::aux::empty_arg_list>, 1>           
> ArgumentPack=boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::boyer_myrvold_params::tag::embedding,const
> boost::bgl_named_params<boost::associative_property_map<VertexDescMap>,boost::vertex_index_t,boost::no_property>>,boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::boyer_myrvold_params::tag::graph,const
> boost::adjacency_list<boost::setS,boost::listS,boost::undirectedS,boost::no_property,boost::no_property>>,boost::parameter::aux::empty_arg_list>> 1>        ] 1>        .\src\main.cpp(135): Siehe Verweis auf die
> Instanziierung der gerade kompilierten Funktions-template "bool
> boost::boyer_myrvold_planarity_test<graph,boost::bgl_named_params<T,Tag,Base>>(const
> A0 &,const A1 &)". 1>        with 1>        [ 1>           
> T=boost::associative_property_map<VertexDescMap>, 1>           
> Tag=boost::vertex_index_t, 1>            Base=boost::no_property, 1>  
> A0=graph, 1>           
> A1=boost::bgl_named_params<boost::associative_property_map<VertexDescMap>,boost::vertex_index_t,boost::no_property> 1>        ]

Em resumo, ele reclama que não pode convertê-lo / usá-lo como eu gostaria.

Como posso fazer isso funcionar?

O que mais eu tenho para dar à função?

Infelizmente, dificilmente há exemplos de reforço para trabalhar com setS ou listS como contêineres. Além disso, não posso usar as tags de propriedade porque isso faz parte de uma implementação maior e preciso manter as propriedades externas.

Eu ficaria muito feliz se alguém tivesse uma sugestão.

questionAnswers(1)

yourAnswerToTheQuestion